Tell us what’s happening:
I don’t understand why is not pass … can somebody help to explain :" 4. When the array has three of the same number, your getHighestDuplicates function should update the Three of a Kind radio option with , score = and the total sum of the dice. " ?
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
function getHighestDuplicates() {
const count = diceValuesArr.reduce((acc, value) => {
acc[value] = (acc[value] || 0) + 1;
return acc;
}, {});
console.log(count);
const maxCount = Math.max(...Object.values(count));
let sumArr =(arr) => arr.reduce((a, b) => a + b, 0);
if (maxCount <= 2) {
updateRadioOption(5, 0);
} else if (maxCount === 3) {
score = sumArr(diceValuesArr)
updateRadioOption(0,score);
console.log(maxCount);
} else {
updateRadioOption(1, sumArr(diceValuesArr));
updateRadioOption(0, sumArr(diceValuesArr));
console.log(maxCount);
};
};
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
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) 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