scrimba
Note at 0:34
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:34
by
AboutCommentsNotes
Note at 0:34
by
Expand for more info
index.js
run
preview
console
const elf = document.getElementById("elf")
const btn = document.getElementById("btn")
const equipbtn = document.getElementById("equipbtn")
const tools = ["☕", "🥧", "🪚", "🔧", "🎄", "🎁", "🍔", "🍟", "🍕", "🌯", "🍙"]
btn.addEventListener("click", duplicateElf)
equipbtn.addEventListener("click", equipElf)

function duplicateElf(){
if(elf.textContent.length<100) elf.textContent += "🧝";
};

function equipElf(){
if(elf.textContent.length<100) {
const random = Math.floor(Math.random() * tools.length);
elf.textContent += tools[random];
}
};
// Stretch goals:
// - Write a function to give the elves some tools, or a cup of tea!
// - Limit the total number of elves to 100.
Console
/index.html
LIVE