main.js
1
2
3
4
5
6
7
function getIndexToIns(arr, num) {
  arr.push(num);
  arr.sort(function(a, b){return a-b});
  return arr.indexOf(num);
}

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