Tell us what’s happening:
I’ve already tested my function and found nothing wrong with it; could you tell me where I’m wrong?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (dice) => {
const diceUnique = [...new Set(dice.sort((a, b) => a - b))];
console.log(diceUnique)
if (diceUnique.length === 5) {
updateRadioOption(4, 40);
return;
}
let isSmallStraight = true;
if(diceUnique.length === 4) {
for (let i = 0; i <= 2; i++) {
if(diceUnique[i] !== diceUnique[i+1] - 1) {
isSmallStraight = false
return;
}
}
} else isSmallStraight = false;
if(isSmallStraight) {
updateRadioOption(3, 30);
return;
}
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/127.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14