Code passes some test but not all so if anyone could help? Thanks.
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
var sort = arr.sort();
var tp = '';
var i;
for (i = 0; i < sort.length; i++) {
if(sort[i] < num ){
tp = sort.indexOf(sort[i]) + 1;
}else if(sort[i] == num){
tp = sort.indexOf(sort[i]) - 1;
}
}
return tp;
}