Report the type of the current timestamp.
Acceptance criteria
- 1.#out should show number.
JavaScript Tutorial · JavaScript Dates
These 10 tasks go with the JavaScript Timestamps 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: “A timestamp is the number of milliseconds since the start of 1970.” .
1.Read a timestampexercise · easy · 10 min
Report the type of the current timestamp.
Passes when: #out should show number.
2.Convert a date to a timestampexercise · easy · 10 min · practice plan
Report whether the round trip keeps the value.
Passes when: #out should show round trip works.
3.Find the epoch yearexercise · easy · 10 min · practice plan
Report the year of timestamp zero.
Passes when: #out should show 1970.
4.Convert seconds to millisecondsexercise · easy · 10 min · practice plan
Multiply by a thousand and report the year.
Passes when: #out should show 2026.
5.Sort by timestampexercise · medium · 10 min · practice plan
Sort the events and report their order.
Passes when: #out should show first,second.
6.Fix the seconds used directlybug fix · easy · 8 min
JavaScript expects milliseconds, so seconds land near 1970.
Passes when: #out should show 2026.
7.Fix getTime called on the classbug fix · easy · 8 min · practice plan
getTime belongs to a date instance, not to Date itself.
Passes when: #out should show a number.
8.Fix the events sorted by namebug fix · easy · 8 min · practice plan
Sorting the names alphabetically ignores when they happened.
Passes when: #out should show beta,alpha.
9.Fix the 1900 offset appliedbug fix · easy · 8 min · practice plan
getFullYear already gives the whole year, with nothing to subtract.
Passes when: #out should show 1970.
10.Fix the elapsed time measured backwardsbug fix · easy · 8 min · practice plan
The start must be subtracted from the end.
Passes when: #out should show not negative.
Between them these tasks cover Date.now, getTime and The epoch.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.