JavaScript history Object — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript history Object 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
Check pushState exists
easy10 minReport the type of history.pushState.
- 2
Build state data
easy10 minBuild a state object and read a property from it.
- 3
Check the history length
easy10 minReport the type of history.length.
- 4
Check replaceState exists
easy10 minReport the type of history.replaceState.
- 5
Push and read state
medium10 minPush a state and read it back from history.state.
Find the bug(5)
- 1
Fix pushState called without an object
easy8 minThe first argument should be the state, not just a string.
- 2
Fix location.reload used to go back
easy8 minGoing back in history is a different action from reloading.
- 3
Fix the state read from the wrong place
easy8 minPushed state is read from history.state, not from the pushState call itself.
- 4
Fix go called with the wrong sign
easy8 minA negative number goes backwards.
- 5
Fix pushState used where replaceState fits
easy8 minReplacing the entry should not add a new one.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace