Tell us what’s happening:
The code is producing the same results asked in the instructions. But still not getting passed. I don’t know where I’m making mistake. Anybody can help please?
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (array) => {
const counts = {};
score = 0;
array.forEach((num) => {
counts[num] = (counts[num] || 0) + 1;
});
const highest = Object.keys(counts).sort(
(a, b) => counts[b] - counts[a]
)[0];
console.log(highest);
console.log(counts[highest]);
if (counts[highest] >= 4) {
score = diceValuesArr.reduce((a, b) => a + b, 0);
updateRadioOption(1, score);
return;
} else if (counts[highest] >= 3) {
score = diceValuesArr.reduce((a, b) => a + b, 0);
updateRadioOption(0, score);
return;
} 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
/* 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
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7