JavaScript Code Reorder Hard +35 XP
Event Listener Setup
Reorder to properly set up a click counter.
Click lines in the correct order
Available lines7 left
Your order
Click lines above to build your solution.
Show answer and explanation
Answer: let count = 0;
const button = document.getElementById("btn");
function handleClick() {
count++;
console.log(count);
}
button.addEventListener("click", handleClick);
Variables and functions must be defined before use. The event listener comes last.
Hint: You can't use a variable before declaring it.
What this challenge tests
Code Reorder in JavaScript: dom, events.