Tell us what’s happening:
I’ve been at this for hours, the function is able to count the right amount of consecutive numbers and update what I think are the right radio buttons, but the console keeps telling me that I’m wrong. The instructions are so confusing sometimes. Any help would be appreciated, thank you.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
let consecutiveCount = 0;
arr.forEach((num, index)=>{
if(index === 0){
consecutiveCount += 1;
return;
}
if(num === arr[index -1] + 1){
consecutiveCount += 1;
}
})
if(consecutiveCount === 5){
updateRadioOption(4, 40);
}
if(consecutiveCount >= 4){
updateRadioOption(3, 30);
}else{
updateRadioOption(5, 0);
}
return consecutiveCount;
}
console.log(checkForStraights([1,2,3,4,5]))
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 (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 14