Practice ยท 3 of 3
Wire a Counter Button
You have button (a button element) and display (a span). Make the button clicks count: keep a count variable, listen for click, and show the new value in display on every click. Then simulate two clicks by calling the handler logic twice, and log the display text (should be 2).
Rules:
- addEventListener("click", โฆ) on the button.
- The display updates inside the handler.
Difficulty: beginner
Press Submit to check your solution.
Back to lesson: Practice: DOM Practice Gym