Tell us what’s happening:
Im not sure what im doing wrong here. It keeps throwing the same error, “your getHighestDuplicates function should update the Three of a Kind radio option with , score = and the total sum of the dice.”
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (arr) =>{
const counts = {};
for (const num of arr){
if(counts[num]){
counts[num]++;
} else{
counts[num] = 1;
}
}
let highestCount = 0;
for(const num of arr){
const count = counts[num];
if(count >= 3 && count > highestCount){
highestCount = count;
}
if(count >= 4 && count > highestCount){
highestCount = count;
}
}
const sumOfAllDice = diceValuesArr.reduce((a,b)=> a+b, 0);
if(highestCount >= 4){
updateRadioOption(1, score = sumOfAllDice);
}
if(highestCount >= 3){
updateRadioOption(0, score = sumOfAllDice);
}
updateRadioOption(5, score = 0)
}
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
/* 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/126.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/review-algorithmic-thinking-by-building-a-dice-game/step-7`Preformatted text`