Tell us what’s happening:
When the array has less than three of the same number, your getHighestDuplicates function should update the final radio option with , score = 0.
I try to fix it But same thing appear every time
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = array =>{
let duplicates ={};
console.log(array);
array.forEach(number=>{
duplicates[number] = (duplicates[number] || 0) + 1 ;
});
console.log(duplicates);
let maxCount = 0;
let maxDuplicate
let sum = array.reduce((sum,value) => sum + value , 0)
for(const [duplicate,count] of Object.entries(duplicate)){
if(count > maxCount){
maxCount = count;
maxDuplicate = duplicate;
}
}
if(maxCount > 3){
updateRadioOption(1 ,`, score =${sum}`)
}
if(maxCount > 2){
updateRadioOption(0 ,`, score =${sum}`)
}
updateRadioOption(5 ,`, score =${sum}`)
}
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7