Tell us what’s happening:
i can’t get to pass the second option which say “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.” I don’t know what I’m missing. i need help on that thank you
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const cleanArr = arr.sort().filter((el, i, a) => i === a.indexOf(el));
const hasFourOrFiveConsecutive = (arr) => {
let n = arr.length;
let mini = Math.min(...arr);
let maxi = Math.max(...arr);
if (maxi - mini + 1 !== n) return false;
for (let i = 0; i < n; i++) {
let val = Math.abs(arr[i]);
if (arr[val - mini] < 0) {
return false;
}
arr[val - mini] *= -1;
}
return true;
}
if (hasFourOrFiveConsecutive(cleanArr) && cleanArr.length === 5) {
updateRadioOption(4, 40);
updateRadioOption(3, 30);
} else if (hasFourOrFiveConsecutive(cleanArr) && cleanArr.length === 4) {
updateRadioOption(3, 30);
}
const test = [2,4,3,1];
console.log(hasFourOrFiveConsecutive(test))
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/136.0.0.0 Safari/537.36 Edg/136.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14