Report the type of history.pushState.
Acceptance criteria
- 1.#out should show function.
JavaScript Tutorial · JavaScript Storage & BOM
These 10 tasks go with the JavaScript history Object 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: “history controls the browser's back and forward navigation stack.” .
1.Check pushState existsexercise · easy · 10 min
Report the type of history.pushState.
Passes when: #out should show function.
2.Build state dataexercise · easy · 10 min · practice plan
Build a state object and read a property from it.
Passes when: #out should show products.
3.Check the history lengthexercise · easy · 10 min · practice plan
Report the type of history.length.
Passes when: #out should show number.
4.Check replaceState existsexercise · easy · 10 min · practice plan
Report the type of history.replaceState.
Passes when: #out should show function.
5.Push and read stateexercise · medium · 10 min · practice plan
Push a state and read it back from history.state.
Passes when: #out should show two.
6.Fix pushState called without an objectbug fix · easy · 8 min
The first argument should be the state, not just a string.
Passes when: #out should show two.
7.Fix location.reload used to go backbug fix · easy · 8 min · practice plan
Going back in history is a different action from reloading.
Passes when: #out should show back is separate.
8.Fix the state read from the wrong placebug fix · easy · 8 min · practice plan
Pushed state is read from history.state, not from the pushState call itself.
Passes when: #out should show two.
9.Fix go called with the wrong signbug fix · easy · 8 min · practice plan
A negative number goes backwards.
Passes when: #out should show backwards.
10.Fix pushState used where replaceState fitsbug fix · easy · 8 min · practice plan
Replacing the entry should not add a new one.
Passes when: #out should show same length.
Between them these tasks cover pushState, popstate and State data.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.