Tell us what’s happening:
I feel like I’m close here, but the tests are failing, and it keeps saying I need to update the displayed text with score = 30 or score = 40. I looked at my functions to check for a full house, 3 of a kind, or 4 of a kind, and they don’t look much different than the checkForStraights function, so I’m confused as to what I’m doing wrong.
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
const sortedArr = arr.sort((a, b) => a - b);
if (sortedArr === [1, 2, 3, 4] || sortedArr === [2, 3, 4, 5] || sortedArr === [3, 4, 5, 6] || sortedArr === [1, 2, 3, 4, 5] || sortedArr === [2, 3, 4, 5, 6]) {
if (sortedArr === [1, 2, 3, 4] || sortedArr === [2, 3, 4, 5] || sortedArr === [3, 4, 5, 6]) {
updateRadioOption(3, 30);
}
if (sortedArr === [1, 2, 3, 4, 5] || sortedArr === [2, 3, 4, 5, 6]) {
updateRadioOption(4, 40);
}
} 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/130.0.0.0 Safari/537.36 Edg/130.0.0.0
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14