All of this code should be inside your getHighestDuplicates function. You should just be calling getHighestDuplicates within the rollDiceBtn event listener.
I did that, and I’m still getting the same response:
const getHighestDuplicates = (arr = diceValuesArr) => {
const counts = {};
let highestCount = 0;
for (const num of arr) {
counts[num] = (counts[num] || 0) + 1;
}
for (const count of Object.values(counts)) {
if (count >= 3 && count > highestCount) {
highestCount = count;
}
}
const highestDuplicate = highestCount;
const total = arr.reduce((sum, value) => sum + value, 0);
updateRadioOption(5, 0);
if (highestDuplicate >= 4) {
updateRadioOption(3, total);
}
if (highestDuplicate >= 3) {
updateRadioOption(2, total);
}
return highestDuplicate;
};
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
rollDice();
updateStats();
getHighestDuplicates(diceValuesArr);
}
});
And this still displays:
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.
6. When the array has four of the same number, your getHighestDuplicates function should update the Four of a Kind radio option with , score = and the total sum of the dice.
7. When the array has four of the same number, your getHighestDuplicates function should also update the Three of a Kind radio option with , score = and the total sum of the dice.