Tell us what’s happening:
i can’t understand how you should set the “, score = 0” and also what’s wrong here
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (dice) => {
const counts = {};
dice.forEach((value) => {
counts[value] = (counts[value] || 0) + 1;
});
const totalScore = dice.reduce((sum, val) => sum + val, 0);
let hasThreeOfKind = false;
let hasFourOfKind = false;
for (const value in counts) {
if (counts[value] >= 4) {
hasFourOfKind = true;
updateRadioOption(1, totalScore);
break;
} else if (counts[value] >= 3) {
hasThreeOfKind = true;
updateRadioOption(0, totalScore);
}
}
if (!hasThreeOfKind) {
updateRadioOption(2, 0);
scoreSpans[2].textContent = ", score = 0";
}
};
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
rollDice();
updateStats();
}
});
// 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/130.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7