Https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-where-do-i-belong/16094

Tell us what’s happening:
I have been trying this single line method that should have worked but I can’t figure out why the “else if()” statement won’t return anything except -1.

  **Your code so far**
// bellow is the code that I'd submitted:
  arr.sort( (a, b) => {return a - b});

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

  return arr.length;
// it ends here

// this is the code I was working on...
   return arr.sort( (a,b) =>{return a - b}).findIndex((value,index,array) =>{if (value >= num){return index;}else if(index >= array.length){return array.length} });
// it ends here
function getIndexToIns(arr, num) { 
   return arr.sort( (a,b) =>{return a - b}).findIndex((value,index,array) =>{
      if (value >= num){
        return index;
      }else if(index >= array.length){
        return array.length
      }
   });
}
 
 getIndexToIns([2, 15, 10], 15);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36.

Challenge: Where do I Belong

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).