Exercise Set 11

Exercise 1 of 6

Call the add function and store the return value. Read about calling functions.

HTML

<button id="showSumButton">Show sum</button>
<p id="sumParagraph">Sum:</p>

JavaScript

var showSumButton = document.getElementById("showSumButton");
var sumParagraph = document.getElementById("sumParagraph");

showSumButton.addEventListener("click", showSum);

function showSum() {
    // your code will appear here
    sumParagraph.innerHTML = "Sum: " + sum;
}

function add(number1, number2) {
    return number1 + number2;
}

You must be signed in to type your code.

Last topic Next exercise