Exercise Set 3

Exercise 1 of 6

Make a variable for your age. If you're having trouble, rewatch the variable video.

HTML

<button id="showAgeButton">Show age</button>
<p id="ageParagraph"></p>

JavaScript

var showAgeButton = document.getElementById("showAgeButton");
var ageParagraph = document.getElementById("ageParagraph");

// your code will appear here

showAgeButton.addEventListener("click", showAge);

function showAge() {
    ageParagraph.innerHTML = "I am " + age + " years old";
}

You must be signed in to type your code.

Last topic Next exercise