Does anyone know what's wrong?

Tell us what’s happening:

Your code so far


function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr = arr.sort((a,b) => a - b);
  Math.floor(num);
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] > num) {
      var index = arr.indexOf(arr[i]);
      return index - 1;
    }
  }
}

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/68.0.3440.84 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/where-do-i-belong

First thing I noticed is your Math.floor(num); line.

That returns a value, it doesn’t change the num value.

For the example you’ve got, when arr[i] = 60, i will equal 1. So then you return 1 - 1, which is 0. That’s not the case.