Review Algorithmic Thinking by Building a Dice Game - Step 3

Tell us what’s happening:

tell me what is wrong with the code for the lesson not being passed for me. even thou the code works
rollDiceBtn.addEventListener(“click”, () => {
let diceValuesArr = ;
for(let i = 0; i<5; i++) {
const randomDie = Math.floor(Math.random() * (6 - 1 + 1)) + 1;

  diceValuesArr.push(randomDie)

}
// diceValuesArr.sort((a, b) => a - b);
listOfAllDice.forEach((dieEl, index)=> {
dieEl.textContent = diceValuesArr[index]

         })

})

Your code so far

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

/* file: styles.css */

/* file: script.js */
// User Editable Region

rollDiceBtn.addEventListener("click", () => {
  let diceValuesArr = [];
   for(let i = 0; i<5; i++) {
    const randomDie = Math.floor(Math.random() * (6 - 1 + 1)) + 1;

      diceValuesArr.push(randomDie)

   }
  //  diceValuesArr.sort((a, b) => a - b);
            listOfAllDice.forEach((dieEl, index)=> {
           dieEl.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/127.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 3

there is no need for the let here. The diceValuesArr is already defined in an earlier step.
This let will redefine it and will not work to update the globally scoped diceValuesArr that the step wanted you to update.

Not sure why you decided to write this value here, but I would just write 6 instead.

thanks for your contribution, but without reassigning it again in d btn event function, the diceValuesArr is adding d previously generated numbers to the arr after the btn is being clicked the second time

you can reassign it, just don’t redeclare it.
Let me know if that is not clear.

yea man, reassinging it worked. code passed. thanks man

no worries. Please note that I am not a man. :slight_smile:

lol. sorry princess, my bad

how about I don’t call you ‘young fella’ and you don’t call me princess?
(it’s condescending)

alrigt, how about referring u with your profile name

1 Like

hbar1st are you a Nigerian, and what’s your niche

I am not Nigerian. I’m not sure what you mean by ‘niche’?

asking your area of specialisation in web dev, if you are a frontend,backend or software dev

I am none-of-the-above. (I am here learning too)

oh, that’s great. keep it up

1 Like