Why wont my solution to this index vale from inputed number work?

I'm going through the algorithms section in FCC and I wrote this code for returning an index value based on the number being less than or equal to a value in the array but I run into problems with this duplicated value, why won't this work?

function getIndexToIns(arr, num) 

  // Find my place in this sorted array.

  var newArr = arr.sort();

  for (var i = 0; i < newArr.length; i++ )
    if (num <= newArr[i]){
      return newArr.indexOf(newArr[i]);
   return arr.length;  

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