main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function getIndexToIns(arr, num) {
  arr.sort(function(a, b) {
    return a - b;
  });

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

  return arr.length;
}

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