Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

I think Ive done everything correct, can you guys help to find the problem

Your code so far

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

/* file: styles.css */

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

const getHighestDuplicates = (arr) => {
  const counts = {};
  let totalScore = 0;
  diceValuesArr.forEach(num => {
    counts[num] = (counts[num] || 0) + 1;
    totalScore += num;
  })
  const maxCount = Math.max(...Object.values(counts));

  if(maxCount >= 4) {
    updateRadioOption(1, totalScore);
    updateRadioOption(0, totalScore);
  } 
  else if (maxCount >= 3) {
    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();
  }
});

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 7

Above you need to use the parameter arr with forEach

Hi there!

You need to call the function with diceValuesArr within the click event callback function.

I did it, there is still smth wrong

  1. 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. 6. When the array has four of the same number, your

getHighestDuplicates

function should update the

Four of a Kind

radio option with

, score =

and the total sum of the dice. 7. 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.
this is what it saying

Use arr parameter, instead of actual array in above cide.

thank you broda, may god bless you

1 Like