Tell us what’s happening:
My code fulfills the required functionality, produces the correct results and works without any errors. Yet my code does not pass. What do I need to do in order to pass?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = (arr) => {
for(let i=0; i<scoreInputs.length; i++){
scoreInputs[i].disabled = true;
scoreSpans[i].textContent = "";
}
total = 0;
let counter = {};
for(let i=0; i<arr.length; i++){
if(counter[arr[i]]){
counter[arr[i]]++;
} else {
counter[arr[i]] = 1;
}
}
console.log(counter);
for (let [key, value] of Object.entries(counter)) {
total += Number(key) * value;
}
let max = 0;
for (let [key, value] of Object.entries(counter)) {
if(value === 3) {
max = 3;
continue;
} else if (value === 4) {
max = 4;
}
}
if(max === 3){
updateRadioOption(0, total);
} else if(max === 4){
updateRadioOption(1, total);
} else {
total = 0;
updateRadioOption(5, total);
}
}
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7