Tell us what’s happening:
I have tried most edge cases with my checkForStraight function. But i keep failing the second test. I dont know what I am doing wrong.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = (array) => {
const reduced = [...new Set(array).values()].toSorted((a, b) => a - b);
const consq = reduced.every((num, i) => i === 0 ? true : (num - reduced[i-1]) === 1);
if (reduced.length === 4 && consq) {
updateRadioOption(3, 30);
}
if (reduced.length === 5 && consq) {
updateRadioOption(4, 40);
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14