scrimba
Note at 0:30
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

Note at 0:30
AboutCommentsNotes
Note at 0:30
Expand for more info
index.js
run
preview
console
const greetingDisplay = document.getElementById("greeting-display")
const btn = document.getElementById("btn")

btn.addEventListener("click", writeGreeting)

const greetings = [
"Santa Claus is coming to town!",
"We wish you a Merry Christmas!",
"Happy holidays!",
"Ho, ho, ho! Merry Christmas!",
"Jingle all the way!",
]

function writeGreeting() {
const randomGreetingNumber = Math.floor(Math.random() * greetings.length);
const randomGreeting = greetings[randomGreetingNumber];

greetingDisplay.innerText = randomGreeting;
}

// writeGreeting();
// console.log(greetings[randomGreetingNumber] + " " + randomGreetingNumber);
// Task:
// Write a function to display a random greeting in the card.

// Stretch goals:
// - Allow the user to input to and from names.
// - Add an input for custom messages.
Console
/index.html
LIVE