Question Details

No question body available.

Tags

javascript dayjs

Answers (1)

Accepted Answer Available
Accepted Answer
January 23, 2026 Score: 3 Rep: 220,901 Quality: Expert Completeness: 60%

This is over-reaching a bit:

currentDate.setMonth(currentDate.getMonth() + 1);

As the loop executes each iteration, another month is added to the initial date. And the initial date is on the 28th, which is late in the month. So on the last iteration of the loop, for October, you're comparing October 28th, which is past the end date so the loop ends:

while (currentDate