function findMagicIndexFastRepeated(array, start = 0, end = (Array.isArray(array) && array.length-1)) {
  if(!Array.isArray(array) || end < start) { return -1; }

  const midIndex = parseInt((start + end)/2);
  const midValue = array[midIndex];

  if(midIndex === midValue) {
    return midValue;
  }

  const left = findMagicIndexFastRepeated(array, start, Math.min(midIndex - 1, midValue));
  if(left !== -1) {
    return left;
  }

  const right = findMagicIndexFastRepeated(array, Math.max(midIndex + 1, midValue), end);
  return right;
}
O(log n)

Handles cases when elements has repeated values

@param array
@param start
@param end
@returns {*}