JS Counter
Build a small counter with one state binding and one render step. Use a button so activation works with keyboard and pointer input.
Where to run this
This example changes a document. Open it in the HTML playground, then select Run code. It runs inside a separate preview.
A practical example
<button id="add" type="button">Add a place</button>
<p id="count" role="status">0 places</p>
<script>
let count = 0;
document.getElementById("add").addEventListener("click", () => {
count += 1;
document.getElementById("count").textContent = count + " places";
});
</script>
What happens
The displayed place count increases with each activation.