Tell us what’s happening:
Does anyone realize solution 1 works and passes until you test it (console,log) it on the last few tests? then it doesn’t even run. Is this solution wrong?
also, can anyone explain why the function must return arr.length?
Your code so far
function getIndexToIns(arr, num) {
arr.sort(function(a,b){
return a-b
});
for (let i = 0; i < arr.length; i++){
if (arr[i] >= num)
return i
}
return arr.length
}
console.log(getIndexToIns(getIndexToIns([], 1));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
.
Challenge: Where do I Belong
Link to the challenge: