I tested the code manually and it outputs the correct values
I do not know why my solution is not correct so far
function getIndexToIns(arr, num) {
let newarr = arr.sort();
let result=0;
for(let index in arr){
if(arr[index]>=num){
result= index
return result
}
}
}
console.log(getIndexToIns(
[10, 20, 30, 40, 50], 30));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
.
Challenge: Where do I Belong
Link to the challenge: