Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

I don’t understand why is not pass … can somebody help to explain :" 4. 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. " ?

Your code so far

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

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

function getHighestDuplicates() {

  const count = diceValuesArr.reduce((acc, value) => {
    acc[value] = (acc[value] || 0) + 1;
    return acc;
  }, {});
  console.log(count);
  
  const maxCount = Math.max(...Object.values(count));
  let sumArr =(arr) => arr.reduce((a, b) => a + b, 0);

  if (maxCount <= 2) {
    updateRadioOption(5, 0);

  } else if (maxCount === 3) {
    score = sumArr(diceValuesArr)
    updateRadioOption(0,score);
    console.log(maxCount);

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

  }  
});

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) 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

Please note that this radio button should be updated to score 0 all the time and not just when there are no duplicates.

Also you should follow the instructions given to make the getHighestDuplicates accept an array of dice values.

Also, your array may be unordered so you should still be able to count duplicates if the numbers are in any order.

I still not pass … I don’t understand what is :" 4. 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." meaning ??? can somebody help to to give more details ?

function getHighestDuplicates() {

  const count = diceValuesArr.reduce((acc, value) => {
    acc[value] = (acc[value] || 0) + 1;
    return acc;
  }, {});
  console.log(count);

  const maxCount = Math.max(...Object.values(count));
  let sumArr = (arr) => arr.reduce((a, b) => a + b, 0);

  if (maxCount === 3) {
    score = sumArr(diceValuesArr);
    updateRadioOption(0, score);

  } else if (maxCount >= 4) {
    score = sumArr(diceValuesArr);
    updateRadioOption(1, score);
  }
  else {
    score = 0;
    updateRadioOption(5, score);
  };
}; 

Okay … done → my code was onlye missing requirement : " Also you should follow the instructions given to make the getHighestDuplicates accept an array of dice values."
Thank you.