Tell us what’s happening:
Hello, I tried every test that I could thought of, they all pass, i check same for the preview, but my code isn’t accepted, i check similar question on the forum, but i don’t find a similar issue to mine.
some array i tested:
[3, 6, 5, 7, 4]
[2, 3, 1, 5, 4]
[1, 2, 3, 4, 6]
[2, 2, 1, 5, 4]
[1, 2, 1, 3, 4]
Btw if someone can modify the example to what a straight is, change 12345 for 13425 for example, gonna be easier for non native english speaker to understand the task.
Your code so far
<!-- file: index.html -->
/* file: script.js */
// User Editable Region
const checkForStraights = (arr) => {
let straightsSet = new Set(arr);
let straightsArray = Array.from(straightsSet);
straightsArray.sort((a, b) => a - b);
for (let i = 0; i <= straightsArray.length - 3; i++) {
let count = 1;
for (let j = i; j < straightsArray.length - 1; j++) {
if (straightsArray[j] + 1 === straightsArray[j + 1]) {
count++;
} else {
break;
}
}
if (count >= 5) {
return updateRadioOption(4, 40);
}
if (count === 4) {
return 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
/* 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/127.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14