I have an empty array:
const timeArray = []
const a = new Date(startTime_minTime)
const b = new Date(startTime_maxTime)
const disabledValueStart = new Date(maxStart)
// where startTime_minTime and startTime_maxTime are only two dates (date and time) and maxStart is the last value
Date.prototype.addHours = function (h) {
this.setTime(this.getTime() + h * 60 * 30 * 1000)
return this
}
// Now I'm trying to do a while to populate the array
while (a <= b) {
timeArray.push(a)
if (a !== disabledValueStart) {
a.addHours(1)
}
}
The problem is that my array has only the last value repeated for the number of elements that should populate it, how do I add one element at a time, so that I have them all at the end and not just the same repeated value?
a,b, anddisabledValueStart.