Exercise Set 3

Exercise 1 of 6

Make a variable called age, and set it to your age. If you're having trouble, rewatch the variable video.


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


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