Exercise Set 9

Exercise 1 of 6

Write the condition to show every number in the array. Refer to the arrays and loops page.

HTML

<button id="showNumbersButton">Show numbers</button>
<p id="numbersParagraph">Numbers:</p>

JavaScript

var showNumbersButton = document.getElementById("showNumbersButton");
var numbersParagraph = document.getElementById("numbersParagraph");

var numbers = [1, 1, 2, 3, 5];

showNumbersButton.addEventListener("click", showNumbers);

function showNumbers() {
    for (var i = 0; // your code will appear here; i++) {
        numbersParagraph.innerHTML = numbersParagraph.innerHTML + " " + numbers[i];
    }
}

You must be signed in to type your code.

Last topic Next exercise