Tell us what’s happening:
I am more worried about learning why than passing the step at the moment. I thought i had it pretty fool proof but when i go through the preview the dice roll “4, 2, 3, 1, 1” did not catch the small straight. Can someone explain why?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (diceValuesArr) => {
const sorted = diceValuesArr.slice().sort((a, b) => a - b).toString();
if (sorted === "1, 2, 3, 4, 5" || sorted === "2, 3, 4, 5, 6") {
updateRadioOption(4, 40);
updateRadioOption(3, 30);
} else if (sorted === "1, 2, 3, 4" || sorted === "2, 3, 4, 5" || sorted === "3, 4, 5, 6") {
updateRadioOption(3, 30);
} 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 (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