JavaScript Dates — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Dates lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Build a date
easy10 minCreate January 15 2026 and report the year.
- 2
Read the month number
easy10 minReport the month number for January.
- 3
Read the day of the month
easy10 minReport the day of the month.
- 4
Parse an ISO string
easy10 minParse a date string and report the year.
- 5
Copy before changing
medium10 minChange a copy and report the original day.
Find the bug(5)
- 1
Fix the month passed as a real number
easy8 minMonths start at zero, so January is 0.
- 2
Fix getDay used for the date
easy8 mingetDay gives the weekday, not the day of the month.
- 3
Fix the original changed
easy8 minSetters modify the date in place, so copy first.
- 4
Fix getYear used
easy8 mingetYear is an old method; getFullYear is the correct one.
- 5
Fix the date built from a loose string
easy8 minOnly the ISO format parses consistently.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace