Tell us what’s happening:
From what I can see my getHighestDuplicates function is working properly, but it is not passing. Here is the feedback I get:
“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.”
(When I get 3 of a kind everything seemingly updates as needed)
**edit: I did find one bug. If I get a 3 of a kind on the first or second roll, and then not on the next roll, the 3 of a kind option still stays enabled.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (array) => {
const counts = {};
const score = diceValuesArr.reduce((acc, el) => acc + el, 0);
array.forEach((el) => {
counts[el] = (counts[el] || 0) + 1;
if (counts[el] >= 4) {
updateRadioOption(1, score);
updateRadioOption(0, score);
updateRadioOption(5, 0);
} else {
if (counts[el] >= 3) {
updateRadioOption(0, score);
updateRadioOption(5, 0);
} 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(diceValuesArr)
}
});
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7