Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

Hi,
i am strugling since long a time and can’t solve this issue.
Please give me a solution, i find it no sense because i can’t go further.
Thank’s.

Your code so far

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

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

const getHighestDuplicates = (arr) => {
  const counts = {};

  arr.forEach(num => {
    counts[num] = (counts[num] || 0) + 1;
  });

  let sumOfDice = arr.reduce((acc, val) => acc + val, 0);
  let isFourOfAKind = false;
  let isThreeOfAKind = false;

  for (const num in counts) {
    if (counts[num] >= 4) {
      isFourOfAKind = true;
      updateRadioOption(1, sumOfDice); 
    } else if (counts[num] >= 3) {
      isThreeOfAKind = true;
      updateRadioOption(0, sumOfDice); 
  }

  if (!isThreeOfAKind) {
    updateRadioOption(0, 0);
  }
  if (!isFourOfAKind) {
    updateRadioOption(1, 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
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 7

You have neglected to pass the function the dice values array here.

Also you were supposed to update the final option too in the function?

Also please note that a four of a kind includes a three of a kind. So if you encounter four of a kind, you should also update the button for three of a kind.

This part looks wrong. What part of the step are you trying to complete here?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.