Tell us what’s happening:
I’ve debugged and tested the function and everything seems to work just fine. Yes, I used a string search for possibilities instead of using math, but it all works the same here. Despite my testing, I still get an error saying that the function doesn’t properly react to a small straight.
I’ve also included some comments to label what code does what. I have no idea what could be wrong. What am I missing here?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
//Joins the array into a string for easy searching
const strArr = arr.join('');
//Checks for large straight and updates large + small straight buttons
if(strArr.includes("12345") || strArr.includes("23456")) {
updateRadioOption(4, 40);
updateRadioOption(3, 30);
return;
}
//Checks for small straight and updates small straight button
if(strArr.includes("1234") || strArr.includes("2345") || strArr.includes("3456")) {
updateRadioOption(3, 30);
return;
}
//Default case
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:129.0) Gecko/20100101 Firefox/129.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14