Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

I’ve been stuck on this one for ages and cant seem to find an answer online either. Could anyone point in the right direction or tell me which bit is wrong?

Your code so far

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

/* file: styles.css */

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

// Example usage when dice are rolled
rollDiceBtn.addEventListener("click", () => {
  if (rolls === 3) {
    alert("You have made three rolls this round. Please select a score.");
  } else {
    rolls++;
    rollDice();
    updateStats();
    getHighestDuplicates(diceValuesArr);
  }
});
const getHighestDuplicates = (arr) => {
  const counts = {};

  // Count occurrences of each number in the array
  for (const num of arr) {
    counts[num] = (counts[num] || 0) + 1;
  }

  let highestCount = 0;

  // Determine the highest count of any number
  for (const count of Object.values(counts)) {
    if (count > highestCount) {
      highestCount = count;
    }
  }

  const sumOfAllDice = arr.reduce((a, b) => a + b, 0);

  // Update radio options based on the highest duplicate count
  if (highestCount >= 4) {
    updateRadioOption(1, sumOfAllDice); // Four of a Kind
  } else if (highestCount >= 3) {
    updateRadioOption(0, sumOfAllDice); // Three of a Kind
  } else {
    updateRadioOption(5, 0); // Neither
  }
};

// Example usage when dice are rolled
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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 7

It would be great to describe the problems you are having in more detail. What testcases are failing? What is being logged in the console? What has your own testing revealed? (Are you able to test and confirm the desired behaviours?)

There is a known issue in this step which you need to be aware of (mentioned several times in this forum when people post about this step) which is that the last option has to be updated to score 0 each time your new function is called (it should not be conditionally updated)