Tell us what’s happening:
If no straight is rolled, your checkForStraights function should not enable the fourth or fifth radio button.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const sortedArray = [...new Set(arr)].sort((a, b) => a - b);
let count = 0;
for(let i=0; i < sortedArray.length; i++){
if (sortedArray[i + 1] === sortedArray[i] + 1) {
count++;
} else {
if(i > 1 && count < 3){
count = 0;
}
}
}
if (count > 3) {
updateRadioOption(4, 40);
updateRadioOption(3, 30);
return;
}
else if (count === 3) {
updateRadioOption(3, 30);
return;
}
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; rv:139.0) Gecko/20100101 Firefox/139.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14