Tell us what’s happening:
Currently failing 3 tests. These tests say I am not updating the corresponding radio buttons with their scores.
I cannot figure what I am doing wrong as in my preview, the needed buttons update with the correct scores and are no longer disabled.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getDiceVals = () => {
return Array.from(listOfAllDice).map(die => Number(die.textContent))
}
const sumOfDice = () => {
return getDiceVals().reduce((acc, die) => acc + die, 0)
}
const clearInputs = () => {
scoreInputs.forEach((input) => {
input.disabled = true;
input.value = 0;
})
scoreSpans.forEach((span) => {
span.textContent = ``
})
}
const getHighestDuplicates = (arr) => {
const arrCounts = [0, 0, 0, 0, 0, 0]
arr.forEach((item) => {
arrCounts[item-1] = arrCounts[item-1] + 1
})
arrCounts.forEach((count) => {
if (count >= 4) {
updateRadioOption(1, sumOfDice())
updateRadioOption(0, sumOfDice())
}
if (count >= 3) {
updateRadioOption(0, sumOfDice())
}
})
updateRadioOption(5, 0)
}
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
rollDice();
const diceValues = getDiceVals()
updateStats();
clearInputs()
getHighestDuplicates(diceValues)
}
});
// 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/138.0.0.0 Safari/537.36 Edg/138.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7