I am trying to add new dates to an array with a while loop, for some reason the first time it loops through it correctly adds it. But the second time it deletes the previous time and adds 2 of the new value.
var currentDate = new Date();
var testDate = new Date(2021, 8, 27, 0, 0, 0, 0);
var displayDate = new Date(2021, 5, 27, 0, 0, 0, 0);
var dateArray = [];
while (d.getTime() + 13 < currentDate.getTime()) {
d.setDate(d.getDate() + 14);
displayDate.setDate(displayDate.getDate() + 14);
console.log(displayDate);
dateArray.push(displayDate);
console.log(dateArray);
}
console.log(dateArray);