Skip to main content

What is JavaScript — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the What is JavaScript 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

    Make the page say something

    easy10 min

    Use JavaScript to put the word "running" into #out.

  2. 2

    Do a calculation in the page

    easy10 min

    Work out 6 times 7 and show the result.

  3. 3

    Read something from the page

    easy10 min

    Read the heading's text and show it.

  4. 4

    Change a style from JavaScript

    easy10 min

    Set #out's colour to red, then report "styled".

  5. 5

    Store and reuse a value

    medium10 min

    Store a browser fact in a variable and show "dynamic".

Find the bug(5)

  1. 1

    Fix the wrong selector

    easy8 min

    The code targets an element that does not exist.

  2. 2

    Fix the misspelled property

    easy8 min

    textContent is spelled wrong, so nothing appears.

  3. 3

    Fix the missing quotes

    easy8 min

    The text is unquoted, so JavaScript looks for a variable.

  4. 4

    Fix the wrong method name

    easy8 min

    querySelectorAll returns a list, not one element.

  5. 5

    Fix the reversed assignment

    easy8 min

    The assignment is written backwards.

Ready to write the code?

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

Open the workspace