Returning arr.length

Towards the end of the code, i don’t understand why arr.length is being returned

  **Your code so far**
function getIndexToIns(arr, num) {
arr.sort((a, b)=> a-b);
for (let i = 0; i < arr.length; i++){
  if (arr[i]>= num){
    return i
  }
}
return arr.length
}

getIndexToIns([40, 60], 50);


  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0

Challenge: Where do I Belong

Link to the challenge:

Because if the value is larger than any of the other values, the index to insert is after the last item.

What were you thinking should be returned instead?

is that not why i is returned inside the if statement?

will i ever have the value of arr.length in the body of the loop?

If you are remove the return arr.length line and run the function with a value larger than any in the array, what is the result?