Report Down when the mouse goes down on the box.
Acceptance criteria
- 1.#out should show Down.
JavaScript Tutorial · JavaScript Events
These 10 tasks go with the JavaScript Mouse Events chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Mouse events report clicks, movement and hovering over an element.” .
1.Handle mousedownexercise · easy · 10 min
Report Down when the mouse goes down on the box.
Passes when: #out should show Down.
2.Record the click orderexercise · easy · 10 min · practice plan
Record mousedown, mouseup and click in the order they fire.
Passes when: #out should show down up click.
3.Report the coordinatesexercise · easy · 10 min · practice plan
Report clientX and clientY separated by a comma.
Passes when: #out should show 30,40.
4.Handle hoveringexercise · easy · 10 min · practice plan
Report Entered when the pointer enters the box.
Passes when: #out should show Entered.
5.Check which buttonexercise · medium · 10 min · practice plan
Report left when button 0 was used.
Passes when: #out should show left.
6.Fix the wrong event namebug fix · easy · 8 min
mousedown is one word with no capital letter.
Passes when: #out should show Down.
7.Fix the coordinates read from the wrong propertiesbug fix · easy · 8 min · practice plan
The pointer position is clientX and clientY.
Passes when: #out should show 30,40.
8.Fix mouseover used for a simple hoverbug fix · easy · 8 min · practice plan
mouseenter is wanted, because it ignores child elements.
Passes when: #out should show Entered.
9.Fix the button number compared to a stringbug fix · easy · 8 min · practice plan
event.button is a number, not text.
Passes when: #out should show left.
10.Fix mouseup listened for instead of mousedownbug fix · easy · 8 min · practice plan
The report should happen as the button goes down.
Passes when: #out should show Down.
Between them these tasks cover click, mousedown and mouseenter.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.