if (raining == false) { console.log(`leave the umbrella`) }
HTML
<button id="richMessageButton">Show message</button> <p id="richMessageParagraph"></p>
JavaScript
let richMessageButton = document.getElementById(`richMessageButton`) let richMessageParagraph = document.getElementById(`richMessageParagraph`) let rich = false richMessageButton.addEventListener(`click`, showRichMessage) function showRichMessage() { if (// your code will appear here) { richMessageParagraph.innerHTML = `Get a job` } }
Your code
Test your code
HTML
<button id="famousMessageButton">Show message</button> <p id="famousMessageParagraph"></p>
JavaScript
let famousMessageButton = document.getElementById(`famousMessageButton`) let famousMessageParagraph = document.getElementById(`famousMessageParagraph`) let famous = true famousMessageButton.addEventListener(`click`, showFamousMessage) function showFamousMessage() { if (// your code will appear here) { famousMessageParagraph.innerHTML = `Everybody knows you` } }
Your code
Test your code
HTML
<button id="lightButton">Flip switch</button> <p id="lightParagraph">Dark</p>
JavaScript
let lightButton = document.getElementById(`lightButton`) let lightParagraph = document.getElementById(`lightParagraph`) let lightOn = false lightButton.addEventListener(`click`, flipSwitch) function flipSwitch() { if (// your code will appear here) { lightParagraph.innerHTML = `Light` lightOn = true } else { lightParagraph.innerHTML = `Dark` lightOn = false } }
Your code
Test your code
Dark
HTML
<button id="turnButton">Take turn</button> <p id="turnParagraph">Player 1's turn</p>
JavaScript
let turnButton = document.getElementById(`turnButton`) let turnParagraph = document.getElementById(`turnParagraph`) let player1Turn = true turnButton.addEventListener(`click`, takeTurn) function takeTurn() { if (// your code will appear here) { turnParagraph.innerHTML = `Player 2's turn` player1Turn = false } else { turnParagraph.innerHTML = `Player 1's turn` player1Turn = true } }
Your code
Test your code
Player 1's turn
HTML
<img src="/img/cat.png" id="cat">
JavaScript
let cat = document.getElementById(`cat`) let catVisible = true cat.addEventListener(`click`, toggleOpacity) function toggleOpacity() { if (catVisible == true) { this.style.opacity = `0%` // your code will appear here } else { this.style.opacity = `100%` catVisible = true } }
Your code
Test your code
HTML
<img src="/img/dog.png" id="dog">
JavaScript
let dog = document.getElementById(`dog`) let dogRotated = false dog.addEventListener(`click`, toggleRotation) function toggleRotation() { if (dogRotated == false) { this.style.transform = `rotate(180deg)` // your code will appear here } else { this.style.transform = `rotate(0deg)` dogRotated = false } }
Your code
Test your code