Review Algorithmic Thinking by Building a Dice Game - Step 3

Tell us what’s happening:

how do solve this so far so far i have my button ,the loop that generates random number ,can someone help please and explain it to me

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region
//here is where the problem is ,right below
  rollDiceBtn.addEventListener("click", () => {
  diceValuesArr = [1,2,3,4,5,];
  for (let i = 0; i < 5; i++) {
    const randomDice = (Math.floor(Math.random() * 6) + 1);
    diceValueArr.push(randomDice);
  }
  listOfAllDice.forEach((die, index) => {die.textContent = diceValuesArr[index]
})

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 3

Hi @kimkiara520

I notice your code has these 4 issues.

  1. You are reassigning the diceValuesArr array to [1,2,3,4,5,].
  2. After generating a random number, you’re pushing it into diceValueArr. I don’t think think that array exists. Note: diceValueArr vs diceValuesArr
  3. There is a syntax error in your event handler. You should declare it like so: rollDiceBtn.addEventListener("click", () => {}). I think the closing }) is missing.
  4. Empty the diceValuesArr before pushing new random numbers on each button click.

I hope that helps.