Tell us what’s happening:
hi, i cannot figure out why my code is not working, i have tried to figure it out with a console.log statement but i dont see which input will make my options 4 and/or 5 enabled… am i missing something ?
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
let sortedArr = arr.toSorted((a,b) => a - b);
let count = 1;
for (let i=0; i < sortedArr.length -1; i++){
if ((sortedArr[i] +1) === sortedArr[i+1]){
++count;
};
};
console.log(sortedArr,count);
if(count === 5){
updateRadioOption(3, 30);
updateRadioOption(4, 40);
return;
}else if (count === 4){
updateRadioOption(3, 30);
return;
}else if (count <= 3) {
updateRadioOption(5,0);
return;
}
}
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
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14