Tell us what’s happening:
Hi,
i am strugling since long a time and can’t solve this issue.
Please give me a solution, i find it no sense because i can’t go further.
Thank’s.
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (arr) => {
const counts = {};
arr.forEach(num => {
counts[num] = (counts[num] || 0) + 1;
});
let sumOfDice = arr.reduce((acc, val) => acc + val, 0);
let isFourOfAKind = false;
let isThreeOfAKind = false;
for (const num in counts) {
if (counts[num] >= 4) {
isFourOfAKind = true;
updateRadioOption(1, sumOfDice);
} else if (counts[num] >= 3) {
isThreeOfAKind = true;
updateRadioOption(0, sumOfDice);
}
if (!isThreeOfAKind) {
updateRadioOption(0, 0);
}
if (!isFourOfAKind) {
updateRadioOption(1, 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
/* 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/128.0.0.0 Safari/537.36 Edg/128.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7