Im making an array that stores a start time and times following that in 40 min intervals.
Basically check, add the start time to the array then increment repeat.
//Array Of All Available times.
var timeArray = [];
//Start time this begins with 9:00
var startTime = new Date(`date setup here`);
//End Time this is 17:00
var endTime = new Date(`date setup here`);
while (startTime < endTime) {
//Push Start Time to Array
timeArray.push(startTime);
//Add 40 minutes to startTime
startTime = new Date(startTime.setMinutes(startTime.getMinutes() +40));
}
Here are screenshots of the logs:
Start and end Times:

Log of Array:

In the array I find it strange why the inital start time of 9 is not index 0 and why the last index is the end time which should of failed the while loop condition.