# Review Algorithmic Thinking by Building a Dice Game - Step 14

Hey everyone

I’m having an issue with the last step of “Review Algorithmic Thinking by Building a Dice Game” in the JS course. When I submit the code below, my answer is not accepted and I receive the message:

If a small straight is rolled, your `checkForStraights` function should enable the fourth radio button, set the value to `30` , and update the displayed text to `, score = 30` .

The console prints:

// running tests
If a small straight is rolled, your `checkForStraights` function should enable the fourth radio button, set the value to `30`, and update the displayed text to `, score = 30`.
If a large straight is rolled, your `checkForStraights` function should enable the fifth radio button, set the value to `40`, and update the displayed text to `, score = 0`.
If a large straight is rolled, your `checkForStraights` function should also enable the fourth radio button, set the value to `30`, and update the displayed text to `, score = 30`.
// tests completed

The issue is that, as far as I can tell, my code does fulfill all of the above requirements, and I don’t know why it’s not being accepted. I’ve tried various tests and everything came back fine. Please let me know what the issue is, and thanks!

``````const checkForStraights = (diceValuesArray) => {
let count = 1;

for (let i = 1; i < diceValuesArray.length; i++) {
if (diceValuesArray[i - 1] === diceValuesArray[i] - 1) {
count++;
} else if (count < 4) {
count = 1;
}
}

if (count === 5) {
} else if (count === 4) {
} else {
}
}

if (rolls === 3) {
} else {
rolls++;
rollDice();
getHighestDuplicates(diceValuesArr);
detectFullHouse(diceValuesArr);
checkForStraights(diceValuesArr);
}
});
``````

hi there, there’s a bug in this step. You must always enable the 5th radio button option when your function is called to pass.

Edit: also your function doesn’t really work to find straights?
I tested it by doing this:
`checkForStraights([1,2,1,3,4]);`

and it wasn’t able to detect a straight.

I just tried that. I changed

``````if (count === 5) {
} else if (count === 4) {
} else {
}
``````

to

``````if (count === 5) {
} else if (count === 4) {
} else {
}
``````

but that didn’t work. Is there a specific way I’m supposed to do it?

you will need to fix your algorithm to detect the straights as it doesn’t work right now.
(for eg try passing it `[2,3,1,5,4]` and see what it does when you click roll)

Also you will need to update the last radio button all the time. (every time the function is called)

1 Like

Ah. I misunderstood what was meant by a straight. I thought the consecutive numbers had to be in consecutive slots (i.e. [1, 2, 3, 4, 5] works but [1, 3, 2, 4, 5] doesn’t.) My bad. Thanks for the clarification!

1 Like

hi! i’m having the same warnings . i tried this:
checkForStraights([1,2,1,3,4]);
and it went through.
here is part of my code:

if (increment === 5){
console.log(‘large’);

}
if (increment === 4){
console.log(‘small’);