Create January 15 2026 and report the year.
Acceptance criteria
- 1.#out should show 2026.
JavaScript Tutorial · JavaScript Dates
These 10 tasks go with the JavaScript Dates chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “The Date object represents a single moment in time.” Read the chapter.
1.Build a dateexercise · easy · 10 min
Create January 15 2026 and report the year.
Passes when: #out should show 2026.
2.Read the month numberexercise · easy · 10 min · practice plan
Report the month number for January.
Passes when: #out should show 0.
3.Read the day of the monthexercise · easy · 10 min · practice plan
Report the day of the month.
Passes when: #out should show 15.
4.Parse an ISO stringexercise · easy · 10 min · practice plan
Parse a date string and report the year.
Passes when: #out should show 2026.
5.Copy before changingexercise · medium · 10 min · practice plan
Change a copy and report the original day.
Passes when: #out should show 15.
6.Fix the month passed as a real numberbug fix · easy · 8 min
Months start at zero, so January is 0.
Passes when: #out should show January.
7.Fix getDay used for the datebug fix · easy · 8 min · practice plan
getDay gives the weekday, not the day of the month.
Passes when: #out should show 15.
8.Fix the original changedbug fix · easy · 8 min · practice plan
Setters modify the date in place, so copy first.
Passes when: #out should show 15.
9.Fix getYear usedbug fix · easy · 8 min · practice plan
getYear is an old method; getFullYear is the correct one.
Passes when: #out should show 2026.
10.Fix the date built from a loose stringbug fix · easy · 8 min · practice plan
Only the ISO format parses consistently.
Passes when: #out should show 2026.
Between them these tasks cover Date, Month numbering and Timestamps.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.