Tell us what’s happening:
Code woun’t pass
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 isLargeStraight = false;
let isSmallStraight = false;
if (sortedArr.length === 5 &&
(sortedArr.join('') === '12345' || sortedArr.join('') === '23456')){
isLargeStraight = true;
} else if (sortedArr.length >= 4) {
const str = sortedArr.join('');
if (str.includes('1234') || str.includes('2345') || str.includes('3456')) {
isSmallStraight = true;
};
}
if (isLargeStraight) {
updateRadioOption(4, 40);
scoreSpans[4].textContent = `, score = 40`;
} else if (isSmallStraight) {
updateRadioOption(3, 30);
scoreSpans[3].textContent = `, score = 30`;
} else {
updateRadioOption(5, 0);
scoreSpans[5].textContent = `, score = 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