scrimba
Frontend Career Path
Essential JavaScript concepts
JS Mini Projects
Debugging: console.error
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
Debugging: console.error
Expand for more info
index.js
run
preview
console
const ageInput = document.getElementById('age')
const resultDisplay = document.getElementById('result-display')
const checkButton = document.getElementById('btn-check')

//set minimum drinking and minimum driving age
const minDrinkAge = 21
const minDriveAge = 16

//check button click event listener
checkButton.addEventListener('click', function () {
let message = ''
const age = ageInput.value
if (age < minDrinkAge && age < minDriveAge) {
message = `I'm sorry, you cannot drink or drive ⛔`
} else if (age >= minDrinkAge && age < minDriveAge) {
message = "You can drink 🍺 but you cannot drive"
} else if (age >= minDriveAge && age < minDrinkAge) {
message = "You can drive 🚗 but you cannot drink"
} else {
message = "You can drink 🍺 and drive 🚗 (not at the same time though!)"
}
renderMessage(message)
})

function renderMessage(message) {
resultDisplay.innerText = message
}


Console
/index.html
-2:24