Practice · 3 of 3
Wire a Counter Button
CHALLENGE
Difficulty: beginner+25 XP
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.
Press Submit to check your solution.
Back to lesson: Practice: DOM Practice Gym