Tell us what’s happening:
The code below returns the correct indexes but it does not pass the tests. Could someone please explain why? Thank you.
**Your code so far**
function getIndexToIns(arr, num) {
arr.sort((a,b) => a - b);
for (let i in arr) {
if (num <= arr[i]) {
return i;
}
}
return arr.length;
}
getIndexToIns([40, 60], 50);
**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: