Exercise Set 5

Exercise 1 of 6

Make a variable so that clicking the button shows a message. Read the Boolean page.

HTML

<button id="showMessageButton">Show message</button>
<p id="messageParagraph"></p>

JavaScript

var showMessageButton = document.getElementById("showMessageButton");
var messageParagraph = document.getElementById("messageParagraph");

// your code will appear here

showMessageButton.addEventListener("click", showMessage);

function showMessage() {
    if (raining == false) {
        messageParagraph.innerHTML = "Leave the umbrella";
    }
}

You must be signed in to type your code.

Last topic Next exercise