Skip to main content

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. 1

    Check pushState exists

    easy10 min

    Report the type of history.pushState.

  2. 2

    Build state data

    easy10 min

    Build a state object and read a property from it.

  3. 3

    Check the history length

    easy10 min

    Report the type of history.length.

  4. 4

    Check replaceState exists

    easy10 min

    Report the type of history.replaceState.

  5. 5

    Push and read state

    medium10 min

    Push a state and read it back from history.state.

Find the bug(5)

  1. 1

    Fix pushState called without an object

    easy8 min

    The first argument should be the state, not just a string.

  2. 2

    Fix location.reload used to go back

    easy8 min

    Going back in history is a different action from reloading.

  3. 3

    Fix the state read from the wrong place

    easy8 min

    Pushed state is read from history.state, not from the pushState call itself.

  4. 4

    Fix go called with the wrong sign

    easy8 min

    A negative number goes backwards.

  5. 5

    Fix pushState used where replaceState fits

    easy8 min

    Replacing 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