Tell us what’s happening:
rollDiceBtn.addEventListener(“click”,()=>{
let count=0;
let diceValuesArr = ;
while(diceValuesArr.length < 5 ){
let random = Math.ceil((Math.random()*6));
diceValuesArr.push(random);
listOfAllDice[count].textContent = random;
count++;
}
The task is to generate 5 random numbers for the array listOfAllDice. I have tried this code and its not working. it says that "When your rollDiceBtn is clicked, the diceValuesArr should contain five elements. I had checked youtube and the code works perfectly in the video. don’t know what’s wrong?!
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
rollDiceBtn.addEventListener("click",()=>{
let count=0;
let diceValuesArr = [];
while(diceValuesArr.length < 5 ){
let random = Math.ceil((Math.random()*6));
listOfAllDice.push(random);
listOfAllDice[count].textContent = diceValuesArr;
count++;
}
// User Editable Region
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 3