Where do I belong? [Solved]

Where do I belong? [Solved]
0.0 0

#1

My code works well except for the case at the bottom. Can someone please tell me why?
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.sort(); //sorts array

var i = 0;
while (arr[i] < num) {

i++;

}

return i;
}

getIndexToIns([5, 3, 20, 3], 5); // 3, 3, 5, 20


#3

Thanks! I was lacking the comparisonFunction in my sort function call! It’s working now. :slight_smile: