Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

Hi there, i have tried my solution for couple of hours, but it seems like there’s an issue with my logic, I’m asking for help after spending a coupon of hours working on it. Any hint would be great please thank you.
When i click on the test button my logic is stock on this step; 2. When the array has less than three of the same number, your

getHighestDuplicates

function should update the final radio option with

, score = 0

.

Your code so far

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

/* file: styles.css */

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

function getHighestDuplicates(array){
  newArr = {};
  for(let el of array){
    if(newArr[el]){
      newArr[el] += 1;
      }else{
        newArr[el] = 1;
      }
  }
  const sumScore = array.reduce((total, num) => total + num, 0);
  const maxIndex = array.length - 1;
  const highest = Object.values(newArr).reduce((a, b) => b > a? b: a, 0);

  
  if(highest >= 4){
    updateRadioOption(1, sumScore);
  }else if(highest >= 3){
    updateRadioOption(0, sumScore)
  }else if(highest < 3){
    updateRadioOption(maxIndex, `, score = 0`)
  }
  return;
}


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/126.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 7

Hi @Davelove

Uncaught ReferenceError: newArr is not defined

There is a message in the console.

Happy coding