Tell us what’s happening:
Describe your issue in detail here.

when i run my code , which i thought i did everything right. i get this in my query. which all other tests have passed the challenge.

getIndexToIns([2, 5, 10], 15) should return a 3.

  **Your code so far**

function getIndexToIns(arr, num) {
for (let i=0; i < arr.length; i++){
 arr.sort(function(a,b){return a-b});

for(let i = 0; i < arr.length; i++){
  if (arr[i]>=num){
    return i;
return num;

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/91.0.4472.164 Safari/537.36

Challenge: Where do I Belong

Link to the challenge:

you have this, but in thay case arr[i] is never bigger than num so this one never run

and so the return statement is this:

in this case it’s 15 which is the wrong answer for the challenge

hmm ok. dang im so close.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.