Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

My issue is, even though I call the function, I’m getting errors concerning that function.
My sum works properly too.

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.

if(fourOfAKind){
updateRadioOption(1,sum);
updateRadioOption(0, sum);
}else if(threeOfAKind){
updateRadioOption(0, sum);
}

Your code so far

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

/* file: styles.css */

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

const getHighestDuplicates = (arr)=>{
  arr = diceValuesArr;
  score = 0;
  let nums = {};
  let threeOfAKind = false;
  let fourOfAKind = false;
  for(let i = 0; i < arr.length; i++)
  {
    score += arr[i];
    if(!nums[arr[i]])
    {
      nums[arr[i]] = 1;
    }else{
      nums[arr[i]] += 1;
    }

    if(nums[arr[i]] == 4){
      fourOfAKind = true;
    }else if(nums[arr[i]] == 3)
    {
      threeOfAKind = true;
    }
  }
  updateRadioOption(5, 0);
  if(fourOfAKind){
    updateRadioOption(1,score);
    updateRadioOption(0, score);
  }else if(threeOfAKind){
    updateRadioOption(0, score);
  }
  console.log(score);
}

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

Your browser information:

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

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 7

don’t do this. You should use the arr as given.

also pass the diceValuesArray to the function when you call it.

Thanks. That fixed it