I'm trying to loop through to check if the first date is less than the second date. If it is, I want to store the value in an array, add 1 day to the first date, then go back through the process. I think that's what I've written, but I'm not sure why it's not working. When I console out any any of the array values, it's always the last date that appears and I can't get any of the other values to store. After stepping through it with Firebug, it looks like they are being overwritten. I'm using moment.js to get the dates.
var counter = 1;
var arr = [];
var i = firstDate.toDate();
for(counter; firstDate < secondDate; counter++){
arr[i]=firstDate.toDate();
firstDate.add(1, "day");
}
console.log(arr[2]);
Any help would be greatly appreciated!