Sorry I'm a beginner and I'm really stuck. I want the following code to PUSH the following dates for me into an array: Jan 01 2017 Mar 31 2017 Apr 01 2017 Jun 30 2017 Jul 01 2017 Sep 30 2017 Oct 01 2017 Dec 31 2017
... etc. Which is correctly coming out of the console.log(s). That's why I'm trying use dates.push(s) to save them in an array. However, it's saving incorrectly; when I print dates[], the array is filled only with "January 1 2022". I can't figure out why
var s = startDate;
var dates = [];
while (s < today) {
console.log(s);
dates.push(s);
s.setMonth(s.getMonth() + 3);
s.setDate(s.getDate() - 1);
dates.push(s);
console.log(s);
s.setDate(s.getDate() + 1);
}
dates.forEach(function(dates) {
console.log(dates);
//this just returns January 1, 2022 over and over
});
Thank you so much for your help!