Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

The game is behaving as expected, I am not sure why the challenge won’t pass

Your code so far

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

/* file: styles.css */

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

const getHighestDuplicates = (numArr) => {
  let count = [0,0,0,0,0,0];
  numArr.forEach((e) => {
    count[e-1]++;
  });
  if (Math.max(...count) >= 3) {
    updateRadioOption(0,diceValuesArr.reduce((acc,cur) => acc+cur,0));
  }
  if (Math.max(...count) >= 4) {
    updateRadioOption(1,diceValuesArr.reduce((acc,cur) => acc+cur,0));
  }
  updateRadioOption(5,0);
}

rollDiceBtn.addEventListener("click", () => {
  if (rolls === 3) {
    alert("You have made three rolls this round. Please select a score.");
  } else {
    rolls++;
    rollDice();
    updateStats();
    getHighestDuplicates(diceValuesArr);
  }
});

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 7

What test are you failing?

Does it give any specific clue? Did you check that?

Can you show how you’ve proved that your program fulfills the test requirement?

When the array has three of the same number, your getHighestDuplicates function should update the Three of a Kind radio option with , score = and the total sum of the dice.

The values are correct and the spans are being updated accordingly

It was a bit confusing bc it was working perfectly fine.

However, your function should work only with the array that is passed as an argument, never the global array.

Changing the reduce calls to use the local array worked, thanks

1 Like