Tell us what’s happening:
Can anyone help pointing out what I’m missing. I have tested it and seems working?
Not passing:
2. If a small straight is rolled, your checkForStraights function should enable the fourth radio button, set the value to 30, update the displayed text to , score = 30 and leave the fifth radio button disabled.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const checkForStraights = arr => {
const sortedArr = arr.sort();
let consecu = 0;
let high = 0;
for (let i = 0; i < 4; i++){
if(sortedArr[i] + 1 === sortedArr[i+1]){
consecu++;
if(consecu > high){
high = consecu;
}
}else{
consecu = 0;
}
console.log(sortedArr[i] + 1=== sortedArr[i+1],sortedArr[i], sortedArr[i+1], consecu);
}
if(high >= 4){
updateRadioOption(4, 40);
}
if(high >= 3){
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([1,2,3,4,6]);
}
});
// 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/140.0.0.0 Safari/537.36
Challenge Information:
Review Algorithmic Thinking by Building a Dice Game - Step 14