Review Algorithmic Thinking by Building a Dice Game - Step 14

Tell us what’s happening:

The code works fine in every case but its still giving error, ive looked over other posts for the same issue but i cant seem to get whats the issue

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const checkForStraights = (arr)=>{
  const sorted = arr.sort();
  let count =1;
  for(let i=0;i<sorted.length-1;i++){
    if(sorted[i]+1 == sorted[i+1]){
        count++
        if(count == 4){
          updateRadioOption(3, 30);
        }
        if(count == 5){
            updateRadioOption(4, 40);
        }
    }
    else{
        count=1;
    }
}
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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 14

Did you do this?

Regardless, it should always update the last radio button to display a score of 0, with the correct attributes.

EDIT: Oops! Sorry. I see it now. Let me test it.

UPDATE: Please test your code with console.log() statements. If you have an array 2,1,3,3,4 your code fails. Maybe think about eliminating duplicates.

1 Like

Thanks a lot , That was the issue