Tell us what’s happening:
I cannot get my code to update the radio options correctly. The combination checker seems to work fine, but if in different dice rolls the results changes the old radio option stays enabled. I think that’t the key of the issue, the radio button should be disabled if the dice changes between rolls in the same round
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (array) => {
const counts = {};
let sumOfDice = 0;
array = diceValuesArr
array.forEach(x => {
counts[x] = (counts[x] || 0) + 1;
});
sumOfDice = array.reduce((acc, curr) => {
return acc + curr;
}, 0);
let flagThree = Array.from(Object.values(counts)).some((x) => x >= 3);
let flagFour = Array.from(Object.values(counts)).some((x) => x >= 4);
if (flagThree && !flagFour) {
updateRadioOption(0, sumOfDice)
}
if (flagFour && !flagThree) {
updateRadioOption(1, sumOfDice)
}
if (!flagFour && !flagThree) {
updateRadioOption(5, 0)
}
}
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
rollDice();
getHighestDuplicates();
updateStats();
}
});
// 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/126.0.0.0 Safari/537.36 Edg/126.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7