Time: 0:00
This is an off-by-one errors bug
The loop that runs one time too many, the slice that drops the last item, the index that starts in the wrong place.
In JavaScript dates, months are numbered from 0 (January) to 11 (December), while days of the month start at 1. getMonth() and getUTCMonth() return that 0-based number, so every month is one behind when displayed. The inconsistency is inherited from Java's original Date API and cannot be changed now. Add 1 whenever you show a month number, and subtract 1 when you build a Date from one. A date that is wrong by exactly one month is almost always this.
The pattern behind it: off-by-one errors.
Paste this into any web page or blog post. Visitors fix the bug right there, in their browser.
<iframe src="https://trybughunt.com/embed/7b9610cb-c11d-4f60-9f8a-c23e476ba081" title="Debugging challenge: Every date shows last month" width="100%" height="580" loading="lazy" style="border:1px solid #d4d4d8;border-radius:12px;max-width:760px"></iframe>
<p style="font-size:14px">Debugging challenge from <a href="https://trybughunt.com/challenges/7b9610cb-c11d-4f60-9f8a-c23e476ba081">BugHunt</a></p>