Tell us what’s happening:
I think my code is working correctly. But it does not pass. I don’t know what I’m missing. I have seen that many people are trying it with .join() and checking the straight options, instead I check if the number is consecutive to the next one in the array. I have tried it with several arrays and it works and does what they ask. can anyone help me? Thanks
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const orderedArr = [...new Set(arr)].sort((a, b) => a - b);
let checkNum = orderedArr[0];
let continuousCount = 0;
for (let i = 0; i < orderedArr.length; i++) {
if (orderedArr[i] === checkNum) {
checkNum++;
continuousCount++;
}
}
if (continuousCount === 5) {
updateRadioOption(4, 40);
updateRadioOption(3, 30);
} else if (continuousCount === 4) {
updateRadioOption(3, 30);
} else {
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