Review Algorithmic Thinking by Building a Dice Game - Step 14

Tell us what’s happening:

My code is failing test 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.
but I can’t see why.

Your code so far

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

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

const checkForStraights = (arr) => {
  let streak = 1;
  let maxStreak = 1

  const sortedArr = arr.sort((a, b) => a - b);

  for (let i = 1; i < sortedArr.length; i++) {
    if (sortedArr[i] === sortedArr[i - 1] + 1) {
      streak++;
      maxStreak = Math.max(maxStreak, streak)
    } else {
      streak = 1;
    };
  }

  if (maxStreak === 4) {
    updateRadioOption (3, 30);
    } else if (maxStreak === 5) {
      updateRadioOption (3, 30);
      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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 14

are you sure your function is able to deal with all straights? like for example [ 1, 2, 2, 3, 4 ]

I see the problem. Thank You.