Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

I am not sure why the code doesn’t pass. i think its the last else statement but i cant tell how. Please assist.

Your code so far

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

/* file: styles.css */

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

const getHighestDuplicates=(arr)=>{
  const countNum = {};
  const summ = arr.reduce((acc, num)=>acc+num, 0)
  let hasThree = false;
  let hasFour = false;

  for(let num in arr){
    countNum[num] = (countNum[num]||0) + 1;
  }
  for(let num in countNum){
    if(countNum[num] >= 4){
      updateRadioOption(1,summ)
      updateRadioOption(0,summ)
    }
    else if(countNum[num] === 3){
      updateRadioOption(0,summ)
    }else{
      updateRadioOption(5,score)
    }
  }

}

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

Okay I managed to solve it, in the first for loop its supposed to be for… of because its iterating through an array. the way i had done it it brings back the index instead of the value. So you should use the for… of loop which iterates through the values. Hope that makes sense

3 Likes