Tell us what’s happening:
I’m not sure what I’m doing wrong here. I took a look at the first solution, and while it’s not exact, (I took an extra step), it seems to line up with what I did. Still I’m not able to pass the test. What am I missing?
Thanks in advance for any help you can offer.
Describe your issue in detail here.
**Your code so far**
function getIndexToIns(arr, num) {
let newArr = arr.sort((a,b)=>a-b);
for (var i = 0; i < arr.length; i++) {
if (newArr[i] >= num) {
return i;
}
else {
return arr.length;
}
}
}
getIndexToIns([40, 60], 50);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36
Challenge: Where do I Belong
Link to the challenge: