Im trying to save the data (date) into the array

42 Views Asked by At

Guys im trying to save it to the array but why it's saving the same in all slots? enter image description here

I'm trying to make a loan sheet that will automatically ads up. I was trying to save the date with 15 days to the array.

1

There are 1 best solutions below

3
Tanaike On

If my understanding of your current issue is correct, I guessed that the reason for your current issue might be due to the pass by reference. In this case, how about the following modification?

From:

array[i] = convert_date;

To:

array[i] = new Date(convert_date); // or new Date(convert_date.getTime());
  • By this modification, the date object of convert_date is copied.