Tell us what’s happening:
In the question it is given that when a large straight is rolled, we should enable the 5th radio button, set the value to 40, and update the displayed text accordingly. But in the hints, it is asking me to enable the 4th radio button and set the value to 30 when a large straight is rolled.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (dice) => {
const sortedDice = [...new Set(dice)].sort((a, b) => a - b);
const largeStraight1 = [1, 2, 3, 4, 5];
const largeStraight2 = [2, 3, 4, 5, 6];
const isLargeStraight = largeStraight1.every(value => sortedDice.includes(value)) ||
largeStraight2.every(value => sortedDice.includes(value));
const smallStraight1 = [1, 2, 3, 4];
const smallStraight2 = [2, 3, 4, 5];
const smallStraight3 = [3, 4, 5, 6];
const isSmallStraight = smallStraight1.every(value => sortedDice.includes(value)) ||
smallStraight2.every(value => sortedDice.includes(value)) ||
smallStraight3.every(value => sortedDice.includes(value));
if (isLargeStraight) {
updateRadioOption(4, 40);
} else if (isSmallStraight) {
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);
}
});
// 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/126.0.0.0 Safari/537.36 Edg/126.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14