Whenever I add elements to an array from a while loop nested inside a for loop, it ends up replacing the previous elements in the array.
var startDate = new Date(theoreticalData[0].UpdateDateMDY);
var newDate = startDate;
var daysDif = 0;
var daysArray = [startDate];
for ( var i= 1; i<theoreticalData.length; i++ ) {
var OldCycle = parseInt(theoreticalData[i].OldCycle);
daysDif = theoreticalData[i].DaysDifference;
while (daysDif > OldCycle ) {
nextDate = this.sumDays(nextDate , OldCycle);
daysArray.push(nextDate);
daysDif = daysDif - OldCycle;
}
nextDate = this.sumDays(nextDate , daysDif);
daysArray.push(nextDate);
}