what im trying to do is that i have a branch that got workhours and so there is more than one services this branch give , so if the client press on service that its duration 15 minutes i need to divide the work hours of the branch into queue list of this duration , from open shift till endshift and also delete all the queues that are on breaktime of the branch
i have this variables:
Startshift="09:10" , breaktime = "12:00" , endBreak="12:30" , endShift="13:00" , period each :10min
i want to define an array of time periods that contain in each cell specific hour according to specific variable i give
myCode:
startTime = 9 , endTime = 13 , selectedServiceDuration = 10 , middleMin = 10
for(i=startTime; i<endTime; i++) {
for(j=middleMin ; j<60; j=j+selectedServiceDuration) {
arr.push({id:Math.random()*56 , hour:i + ":" + (j===0 ? "00" : j)} );
}
}
it will return this way
"hour": "9:10",
"hour": "9:20",
"hour": "9:30",
"hour": "9:40",
"hour": "9:50",
"hour": "10:10",
"hour": "10:20",
"hour": "10:30",
"hour": "10:40",
"hour": "10:50",
"hour": "11:10",
"hour": "11:20",
"hour": "11:30",
"hour": "11:40",
"hour": "11:50",
"hour": "12:10",
"hour": "12:20",
"hour": "12:30",
"hour": "12:40",
"hour": "12:50",
so my code missed hour : 10:00 so that mean the rest of the tabe is incorrect
>Solution :
You have start loop from 10 and end to the 60. and then check j with value 60 because your loop is start from 10 it is not going reverse
Here down is modified code:
for(i=startTime; i<endTime; i++) {
for(j=10; j<=60; j=j+selectedServiceDuration) {
arr.push({id:Math.random()*56 , hour:(j===60) ? i+1 : i + ":" + (j===60 ? "00" : j)} );
}
}