Tell us what’s happening:
I totally changed my logic and again it seems to work but for some reason I am still stuck and not getting it right
Any help would be welcome. Thanks
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
};
const checkForStraights = (arr) => {
const sortedArray = [...arr].sort((a,b) => a - b);
console.log(sortedArray);
const uniqueValuesArr = [...new Set(sortedArray)].join("");
console.log(uniqueValuesArr);
const smallStraight = ["1234", "2345", "3456"];
const largeStraight = ["12345", "23456"];
if (largeStraight.some(straight => uniqueValuesArr.includes(straight))) {
updateRadioOption(4, 40);
}
else if (smallStraight.some(straight => uniqueValuesArr.includes(straight))) {
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14