I've been working on a code to increment the days in a date variable every third iteration using modulus.
While I have managed to get the logic for every third iteration right, the day doesn't seem to increase by 1. I searched online and found suggestions to use
date.setDate(date.getDate() + 1);
, which I incorporated into my code. However, it only increments once and then remains stagnant.
Below is the code snippet of what I have experimented with:
for (let i = 0; i < 10; i++) {
let date = new Date();
if (i % 3 == 0) {
date.setDate(date.getDate() + 1);
console.log(date);
}
}