main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
function getIndexToIns(arr, num) {
  arr.sort(function(a, b) {
  return a - b;
  });
  var i = 0;
  while (num > arr[i]) {
  i++;
  }
  return i;
}


getIndexToIns([40, 60], 50);
Native Browser JavaScript