Tell us what’s happening:
I am receiving the following error when checking my code:
“If a large straight is rolled, your checkForStraights function should also enable the fourth radio button, set the value to 30, and update the displayed text to , score = 30.”
Which doesn’t make sense because a large straight would be the 5th button with a value of 40. When I change the values I pass into updateRadio options with 5 and 30 as suggested by the error I then receive this error:
“If a large straight is rolled, your checkForStraights function should enable the fifth radio button, set the value to 40, and update the displayed text to , score = 0.”
This error makes no sense to me; if a large straight is rolled why would the score be 0?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const sortedNumbersArr = arr.sort((a, b) => {
return a - b;
});
const uniqueNumbersArr = [...new Set(sortedNumbersArr)];
const uniqueNumbersStr = uniqueNumbersArr.join("");
const smallStraightsArr = ["1234", "2345", "3456"];
const largeStraightsArr = ["12345", "23456"];
if (smallStraightsArr.includes(uniqueNumbersStr)) {
updateRadioOption(3, 30);
} else if (largeStraightsArr.includes(uniqueNumbersStr)) {
updateRadioOption(4, 40);
} 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 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14