I'm encountering an issue with my array of dates where they all end up being the same date when I try to retrieve them.
var paydates = new Array();
var i;
var firstDate = new Date();
firstDate.setFullYear(2010, 11, 26); //setting the initial date as 12/26/10
for (i=0; i < 200; i++) //adding 200 dates to the array
{
paydates[i] = firstDate;
firstDate.setDate(firstDate.getDate()+14); //incrementing the date by 14 days
document.write("1st: " + i + ":" + paydates[i] + "<br />");
//dates are displayed correctly here
}
//when attempting to retrieve the dates:
for (i=0; i < 200; i++)
{
document.write("2nd: " + i + ":" + paydates[i] + "<br />");
//this shows 200 instances of the same date
}
I'm struggling to figure out what's causing this issue. Any help would be appreciated.
Thank you