Where do I belong

Where do I belong
0

#1

Tell us what’s happening:
what the array isnt sorting?

Your code so far

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

getIndexToIns([5,3,20,3], 5);

Your browser information:

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

Link to the challenge:


#2

By default, Array.sort() sorts alphabetically. You will need to implement a sorting function in order to sort the array numerically. The documentation tells you how to do this.