I have a Vue js frontend where I have the following while loop with the following:
while (this.day.getDay() != 0) {
console.log(this.day)
this.days.push(this.day)
this.dates.push(this.day.toDateString())
this.day.setDate(this.day.getDate() + 1)
}
The loop outputs the following in the console.
I instantiate the variables as:
day: new Date(Date.now()),
dates: [],
days:[]
I'm wondering why the dates array works correctly and contains sep 6, sep7 and sep 8 but the days array only has sep 09 three times? It is also strange that when I log this.day it logs the correct days but then does not add that to the days array. What is going on here?