This is yielding probably like half of the tests wrong. Let me know what you see as a problem. Thanks for any and all help - really banging my head against the wall on this one
function getIndexToIns(arr, num) {
arr.sort(function(a, b) {
return a - b;
});
for (let i = 0; i < arr.length; i++) {
if (arr[i] <= num) {
return i;
} else {
return arr.length;
}
}
}
console.log(getIndexToIns([2, 20, 10], 19));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36
.
Challenge: Where do I Belong
Link to the challenge: