Skip to main content

JavaScript navigator Object — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript navigator 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 the online state type

    easy10 min

    Report the type of navigator.onLine.

  2. 2

    Read the language

    easy10 min

    Report the type of navigator.language.

  3. 3

    Check for a feature

    easy10 min

    Write a function that checks for clipboard support.

  4. 4

    Check languages is a list

    easy10 min

    Report whether navigator.languages is an array.

  5. 5

    Check userAgent exists

    medium10 min

    Report the type of navigator.userAgent.

Find the bug(5)

  1. 1

    Fix the type check inverted

    easy8 min

    The check for a boolean was written backwards.

  2. 2

    Fix the browser name checked instead of the feature

    easy8 min

    Checking for the feature itself is more reliable than the browser name.

  3. 3

    Fix languages read as one string

    easy8 min

    navigator.languages is a list of preferences, not a single string.

  4. 4

    Fix clipboard called before checking for it

    easy8 min

    Test for the feature before relying on it, in case it is missing.

  5. 5

    Fix the wrong case used for onLine

    easy8 min

    The property is spelled onLine with a capital L.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace