Tell us what’s happening:
Hello,
I am not understanding why I cannot pass test 4. If not straight is rolled, your checkForStraights function should not enable the fourth or fifth radio button.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const sorted = new Set([...arr.sort((a, b) => a - b)]);
let consecutiveCount = 0;
const sortedArr = [...sorted];
for (let i=0; i<sortedArr.length; i++) {
if (sortedArr[i + 1] > sortedArr[i] && sortedArr[i + 1] - sortedArr[i] === 1) {
consecutiveCount++;
}
}
console.log(consecutiveCount);
if (consecutiveCount === 4) {
updateRadioOption(3, 30);
updateRadioOption(4, 40);
} else if (consecutiveCount === 3) {
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
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14