scrimba
Note at 0:00
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:00
AboutCommentsNotes
Note at 0:00
Expand for more info
index.js
run
preview
console
let dice = document.getElementsByClassName("dice")[0];
let dots = document.getElementsByClassName("dot");

dice.addEventListener("click", () => {
let random = Math.floor(Math.random() * 6 + 1)
console.log(random);
for(let x of dots) {
x.style.visibility = "hidden"
}

if(random == 1) {
dots[4].style.visibility = "visible";
} else if (random == 2) {
dots[0].style.visibility = "visible";
dots[8].style.visibility = "visible";
} else if (random == 3) {
dots[0].style.visibility = "visible";
dots[8].style.visibility = "visible";
dots[4].style.visibility = "visible";
} else if (random == 4) {
dots[0].style.visibility = "visible";
dots[2].style.visibility = "visible";
dots[6].style.visibility = "visible";
dots[8].style.visibility = "visible";
} else if (random == 5) {
dots[0].style.visibility = "visible";
dots[2].style.visibility = "visible";
dots[6].style.visibility = "visible";
dots[8].style.visibility = "visible";
dots[4].style.visibility = "visible";
} else if (random == 6) {
dots[0].style.visibility = "visible";
dots[2].style.visibility = "visible";
dots[3].style.visibility = "visible";
dots[5].style.visibility = "visible";
dots[6].style.visibility = "visible";
dots[8].style.visibility = "visible";
}




})
Console
1
,
6
,
5
,
3
,
3
,
5
,
2
,
4
,
1
,
2
,
6
,
6
,
2
,
2
,
5
,
1
,
1
,
3
,
/index.html
LIVE