Here's the code I'm working on:
function populateDates() {
var start = new Date(2017, 7, 13);
var end = new Date(2017, 8, 3);
var tempDate = start;
var endPlus90 = end.setDate(end.getDate() + 90);
var today = new Date();
var array = [];
for(var d = start; d < today || d < endPlus90; d.setDate(d.getDate() + 1)){
if (d.getDay() !== 0 && d.getDay() !== 6){
array.push([d]);
}
}
return array;
}
var future = new Date();
future.setDate(future.getDate() + 90);
console.log(populateDates(new Date(), future));
Basically, what I'm trying to do is, given an arbitrary start and end date, generate a list of dates, excluding weekends, from the start date to either 90 days after the end date, or the current date, whichever is earlier. The current function generates an array that is all identical dates which are 90 days after the end date. I'm not very familiar with Javascript, so I'm not sure what's going wrong here. I suspect that the way I'm pushing the variable to the array is incorrect.