Tell us what’s happening:
I have tried several different methods but kept getting back that it wasn’t updating the inputs correctly. I switched to try this method but it is now telling me i don’t have the function at all. Where am i going wrong here? Please do not give me the answer. What method should i be looking at? Am i missing something?
I will comment down below with what i tried to use just before this. I want to understand where i am going wrong not just fix it…
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const getHighestDuplicates = () => {
let score = 0;
for(let i = 0; i < diceValuesArr.length; i++){
let count = 1;
for(let j = 0; j < diceValuesArr.length; j++){
if(j !=== i && diceValuesArr[i] === diceValuesArr[j]){
count++;
}
};
if(count >= 3){
score = diceValuesArr.reduce((acc, val) => acc + val);
updateRadioOption(0, score)
} else if(count >= 4){
score = diceValuesArr.reduce((acc, val) => acc + val);
updateRadioOption(1, score)
} 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();
getHighestDuplicates();
updateStats();
}
});
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7