Shows how many numbers in the array are smaller than the number provided.
function getIndexToIns(arr, num) {
// Counter variable for results
var count = 0;
for (var i = 0; i < arr.length; i++) {
// If array value - number is negative, it is a smaller number
if (arr[i] - num < 0) {
// Therefore, return count with a value of 1
count = count + 1;
}
}
// Else return regular count which is 0 and means it is a bigger number
return count;
}
getIndexToIns([40, 60], 50);