Tell us what’s happening:
please help solving this; direct me please…
function getHighestDuplicates(dice) {
const counts = {};
dice.forEach(num => {
counts[num] = (counts[num] || 0) + 1;
});
const totalScore = dice.reduce((acc, num) => acc + num, 0);
if (counts >= 4) {
updateRadioOption(0, totalScore);
} else if (counts >= 3) {
updateRadioOption(1 , totalScore);
} else {
updateRadioOption(5 , 0);
}
}
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
function getHighestDuplicates(dice) {
const counts = {};
dice.forEach(num => {
counts[num] = (counts[num] || 0) + 1;
});
const totalScore = dice.reduce((acc, num) => acc + num, 0);
if (counts >= 4) {
updateRadioOption(0, totalScore);
} else if (counts >= 3) {
updateRadioOption(1 , totalScore);
} else {
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(dice);
console.log(counts)
}
});
// 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/127.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7