myButton.addEventListener(`click`, doSomething)
HTML
<button id="greetingButton">Say greeting</button> <p id="greetingParagraph"></p>
JavaScript
let greetingButton = document.getElementById(`greetingButton`) let greetingParagraph = document.getElementById(`greetingParagraph`) // your code will appear here function sayGreeting() { greetingParagraph.innerHTML = `Welcome to the first exercise set` }
Your code
Test your code
HTML
<button id="jokeButton">Tell joke</button> <p id="jokeParagraph"></p>
JavaScript
let jokeButton = document.getElementById(`jokeButton`) let jokeParagraph = document.getElementById(`jokeParagraph`) // your code will appear here function tellJoke() { jokeParagraph.innerHTML = `What do you call 2000 mockingbirds?` }
Your code
Test your code
HTML
<button id="answerButton">Show answer</button> <p id="answerParagraph"></p>
JavaScript
let answerButton = document.getElementById(`answerButton`) let answerParagraph = document.getElementById(`answerParagraph`) // your code will appear here function showAnswer() { answerParagraph.innerHTML = `Two kilo mockingbird` }
Your code
Test your code
HTML
<p id="textParagraph">Click me</p>
JavaScript
let textParagraph = document.getElementById(`textParagraph`) // your code will appear here function changeText() { textParagraph.innerHTML = `Good job!` }
Your code
Test your code
Click me
HTML
<img src="/img/cat.png" id="cat"> <p id="catParagraph"></p>
JavaScript
let cat = document.getElementById(`cat`) let catParagraph = document.getElementById(`catParagraph`) // your code will appear here function makeCatSound() { catParagraph.innerHTML = `Meow` }
Your code
Test your code
HTML
<img src="/img/dog.png" id="dog"> <p id="dogParagraph"></p>
JavaScript
let dog = document.getElementById(`dog`) let dogParagraph = document.getElementById(`dogParagraph`) // your code will appear here function makeDogSound() { dogParagraph.innerHTML = `Woof` }
Your code
Test your code