Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

my code is working, but it is not being accepted, I tried a cumulative score, but also doesnt work
error:
When the array has four of the same number, your getHighestDuplicates function should also update the Three of a Kind radio option with , score = and the total sum of the dice.

I tried the cumulative score because of the error that says four of the same number for a Three of a Kind radio option, code works but still doesnt pass.

Your code so far

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

/* file: styles.css */

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



function getHighestDuplicates (diceValues) {
  const frequencyMap = {};
  diceValues.forEach(value => {
    frequencyMap[value] = (frequencyMap[value] || 0) + 1;
  });

  const totalScore = diceValues.reduce((sum, value) => sum + value, 0);

  let hasFourOfAKind = false;
  let hasThreeOfAKind = false;

  Object.values(frequencyMap).forEach(count => {
    if (count >= 4) {
      hasFourOfAKind = true;
    } else if (count >= 3) {
      hasThreeOfAKind = true;
    }
  });

  if (hasFourOfAKind) {
    
    updateRadioOption(1, totalScore);
  } else if (hasThreeOfAKind) {
  
    updateRadioOption(0, totalScore);
  } else {
 
    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) 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 7

Welcome to the forum @ihmusarevalo02

Try removing the else keyword.

Remove the else condition from the last option.

Happy coding

Try this:

image

ive got it after trying again and analyzing the exact error message over and over.
gotta have patience and better comprehension of error messages

When the array has four of the same number, your getHighestDuplicates function should also update the Three of a Kind radio option