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.
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (diceValuesArr) => {
const duplicates = {};
let maxCount = 0;
for (const value of diceValuesArr) {
duplicates[value] = (duplicates[value] || 0) + 1;
if (duplicates[value] > maxCount) {
maxCount = duplicates[value];
}
}
return { maxCount };
}
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
rollDice();
updateStats();
const { maxCount } = getHighestDuplicates(diceValuesArr);
const totalSum = diceValuesArr.reduce((sum, value) => sum + value, 0);
if (maxCount >= 4) {
updateRadioOption(1, totalSum);
} else if (maxCount >= 3) {
updateRadioOption(0, totalSum);
}
else{
updateRadioOption(5, 0);
}
}
});
// 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
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7