$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #208

Which fix removes the bug?

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