scrimba
Helen Chong's JavaScriptmas 2023 Day 24 solution
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

Helen Chong's JavaScriptmas 2023 Day 24 solution
AboutCommentsNotes
Helen Chong's JavaScriptmas 2023 Day 24 solution
Expand for more info
index.js
run
preview
console
/**
* 🎄 Challenge:
* 1. The Christmas tree's lights should switch
* on and off every 800 miliseconds.
*
* Stretch Goal:
* Make the blue and red lights flash alternately.
**/

const redLightsEl = document.getElementsByClassName('red')
const blueLightsEl = document.getElementsByClassName('blue')

setInterval(() => {
for (let i = 0; i < redLightsEl.length; i++) {
redLightsEl[i].classList.toggle('lights-on')
}

setTimeout(() => {
for (let i = 0; i < blueLightsEl.length; i++) {
blueLightsEl[i].classList.toggle('lights-on')
}
}, 800)
}, 800)
Console
/index.html
LIVE