Tell us what’s happening:
I’m struggling a bit here. The code does seem to work in that it adds the message “, score = 0” to the last radio button but the checker tells me I still need to update this.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = ()=>{
let duplicates = {};
let diceTotal = diceValuesArr.reduce((acc, el) => acc + el, 0);
listOfAllDice.forEach(el => {
if (duplicates.hasOwnProperty(el.textContent)) {
duplicates[el.textContent]++;
} else {
duplicates[el.textContent] = 1;
}
});
for (let key in duplicates){
if(duplicates[key] >= 4){
updateRadioOption(1,diceTotal)
}
else if(duplicates[key] >= 3) {
updateRadioOption(0,diceTotal)
}
else if(duplicates[key] < 3){
updateRadioOption(5, 0)
}
}
};
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/126.0.0.0 Safari/537.36 Edg/126.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7