sim
1
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
for(var i = 0; i < arr.length ; i++){
arr.sort();
if(num <= arr[i]){
return arr.indexOf(arr[i]);
}
}
return arr.length;
}
getIndexToIns([3,5,20], 3);
can you please tell me whats wrong with my code? i cant get the output for this one.
DIFYZ
3
try this:
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
for(var i = 0; i < arr.length ; i++){
arr.sort(function(a,b){return a-b;})
if(num <= arr[i]){
return arr.indexOf(arr[i]);
}
}
return arr.length;
sim
4
thank you so much!!! i finally got it
sim
5
thanks a lot i got it now