Tell us what’s happening:
The test passes but the code I found online seems to be incorrect can someone please explain what is happening here. Thanks
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function checkForStraights(arr){
console.log(arr);
const sorted = arr.sort((a,b)=>a-b);
console.log(sorted);
const difference = (sorted[4]-sorted[3])+(sorted[3]-sorted[2])+(sorted[2]-sorted[1])+(sorted[1]-sorted[0]);
console.log(difference);
if(difference === 5 || difference === 3){
updateRadioOption(3, 30);
}
if(difference === 4){
updateRadioOption(3, 30);
updateRadioOption(4, 40);
}
else{
updateRadioOption(5, 0);
}
}
rollDiceBtn.addEventListener("click", () => {
if (rolls === 3) {
alert("You have made three rolls this round. Please select a score.");
} else {
rolls++;
resetRadioOptions();
rollDice();
updateStats();
getHighestDuplicates(diceValuesArr);
detectFullHouse(diceValuesArr);
checkForStraights(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/130.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14