Tell us what’s happening:
please, can somebody help me?
If a small straight is rolled, your checkForStraights function should enable the fourth radio button, set the value to 30, update the displayed text to , score = 30 and leave the fifth radio button disabled.
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const setArray = [...new Set(arr)];
const sortedArr = setArray.sort((a, b) => a - b);
let consecutiveNumber = 1;
for (let i = 1; i < sortedArr.length; i++) {
sortedArr[i] === sortedArr[i - 1] + 1 ? consecutiveNumber++ : consecutiveNumber = 1;
}
if (consecutiveNumber >= 5) {
updateRadioOption(4, 40);
updateRadioOption(3, 30);
return
}
if (consecutiveNumber === 4) {
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);
}
});
// User Editable Region
/* file: styles.css */
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14