Skip to main content

JavaScript Mouse Events — exercises and bug fixes

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

    Handle mousedown

    easy10 min

    Report Down when the mouse goes down on the box.

  2. 2

    Record the click order

    easy10 min

    Record mousedown, mouseup and click in the order they fire.

  3. 3

    Report the coordinates

    easy10 min

    Report clientX and clientY separated by a comma.

  4. 4

    Handle hovering

    easy10 min

    Report Entered when the pointer enters the box.

  5. 5

    Check which button

    medium10 min

    Report left when button 0 was used.

Find the bug(5)

  1. 1

    Fix the wrong event name

    easy8 min

    mousedown is one word with no capital letter.

  2. 2

    Fix the coordinates read from the wrong properties

    easy8 min

    The pointer position is clientX and clientY.

  3. 3

    Fix mouseover used for a simple hover

    easy8 min

    mouseenter is wanted, because it ignores child elements.

  4. 4

    Fix the button number compared to a string

    easy8 min

    event.button is a number, not text.

  5. 5

    Fix mouseup listened for instead of mousedown

    easy8 min

    The report should happen as the button goes down.

Ready to write the code?

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

Open the workspace