Tell us what’s happening:
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.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = arr =>
{
const sortedArr = [...new Set(arr)].sort((a,b) => a - b);
let consecutiveCount = 1;
for (let i = 1; i < sortedArr.length; i++)
{
if (sortedArr[i] === sortedArr[i - 1] + 1)
{
consecutiveCount++
}
else
{
consecutiveCount = 1;
}
}
if (consecutiveCount === 4)
{
updateRadioOption(3, 30);
}
if (consecutiveCount === 5)
{
updateRadioOption(4, 40);
}
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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14