Tell us what’s happening:
step7, I tried a 2d for loop to check for duplicates, but it does’nt work
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function getHighestDuplicates(arr){
let dup = 0
let sum = 0
for(let i = 0;i<=arr.length;i++){
sum += arr[i]
for(let l = 0;l<=arr.length;l++){
if(arr[i]===arr[l]){
dup++
}
}
}
if(dup==3){
updateRadioOption(0,sum)
}else if(dup==4){
updateRadioOption(1,sum)
}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()
}
});
// 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
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 7