Tell us what’s happening:
My code is working when I manually pass in checkForStraights([1, 2, 3, 4, 5])
. It tells me if a large straight is rolled that it should also enable the 4th radio button with a score = 30, but that’s what is happening. Small is getting 30, large is getting 40, and none is getting 0. All final 3 options are enabled.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const largeStraightRules = [
arr.includes(1),
arr.includes(2),
arr.includes(3),
arr.includes(4),
arr.includes(5)
];
const smallStraightRulesLow = [
arr.includes(1),
arr.includes(2),
arr.includes(3),
arr.includes(4)
];
const smallStraightRulesHigh = [
arr.includes(2),
arr.includes(3),
arr.includes(4),
arr.includes(5)
];
if (largeStraightRules.every(rule => rule)) {
updateRadioOption(4, 40);
}
if (smallStraightRulesLow.every(rule => rule) || smallStraightRulesHigh.every(rule => rule)) {
updateRadioOption(3, 30);
}
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);
checkForStraights([1, 2, 3, 4, 5]);
}
});
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14