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

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

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

  if(midIndex > midValue) {
    return findMagicIndex2(array, midIndex + 1, end);
  }

  if(midIndex < midValue) {
    return findMagicIndex2(array, 0, midIndex);
  }
}
O(log n)

breaks when elements values are repeated

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