Which fix removes the bug?
const d = new Date(2026, 2, 5); console.log(d.getDay()); // expected 5
- Use
getMonth()instead - Use
getUTCDay()here - Use
getDate()instead - Pass the month as 3
getDay() is the weekday (0 = Sunday); the day of the month comes from getDate().
Play Problem Solving ▸