Exercise Set 4

Exercise 1 of 6

Watch the incrementing variable video. Increase the counter when the button is clicked.


<button id="increaseCounterButton">Increase counter</button>
<p id="counterParagraph">Counter: 0</p>


var increaseCounterButton = document.getElementById("increaseCounterButton");
var counterParagraph = document.getElementById("counterParagraph");

var counter = 0;

increaseCounterButton.addEventListener("click", increaseCounter);

function increaseCounter() {
    // your code will appear here
    counterParagraph.innerHTML = "Counter: " + counter;

You must be signed in to type your code.

Last topic Next exercise