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