Review Algorithmic Thinking by Building a Dice Game - Step 14

I try to build solution for checkForStraights function, but my solution didn’t pass the tests. How I can fix this?

function checkForStraights(arr) {
  let sortedArr = arr.sort((a, b) => a - b);
  let count = 1;

  for (let i = 1; i < sortedArr.length; i++) {
    if (sortedArr[i] === sortedArr[i-1] + 1) {
      count++;
    }
    if (sortedArr[i] > sortedArr[i-1] + 1) {
      break;
    }
  }

  if (count === 4) {
    updateRadioOption(3, 30);
  }
  else if (count === 5) {
    updateRadioOption(4, 40);
  }

  updateRadioOption(5, 0);
}

Your browser information:

User Agent is: (Windows NT 10.0; Win64; x64) Chrome/135.0.7049.85

Challenge information

arrays that have small straight but your function does not recognise:

[ 1, 3, 4, 5, 6 ]

then, when there is a large straight you also must enable the radio button for small straight, as a big straight contains a small straight

I like the logic you used here to handle possible duplicates without using Set()!