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
Handle mousedown
easy10 minReport Down when the mouse goes down on the box.
- 2
Record the click order
easy10 minRecord mousedown, mouseup and click in the order they fire.
- 3
Report the coordinates
easy10 minReport clientX and clientY separated by a comma.
- 4
Handle hovering
easy10 minReport Entered when the pointer enters the box.
- 5
Check which button
medium10 minReport left when button 0 was used.
Find the bug(5)
- 1
Fix the wrong event name
easy8 minmousedown is one word with no capital letter.
- 2
Fix the coordinates read from the wrong properties
easy8 minThe pointer position is clientX and clientY.
- 3
Fix mouseover used for a simple hover
easy8 minmouseenter is wanted, because it ignores child elements.
- 4
Fix the button number compared to a string
easy8 minevent.button is a number, not text.
- 5
Fix mouseup listened for instead of mousedown
easy8 minThe 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