searchInsert = function(nums, target, start =  0) {
  if (!nums.length) return start;
  const i = parseInt(nums.length / 2, 10);

  if (nums[i] === target) {
    return start + i;
  } else if (target > nums[i]) {
    const newArray = nums.slice(i + 1);
    if (!newArray.length) return start + i + 1;
    return searchInsert(newArray, target, start + i + 1);
  } else {
    return searchInsert(nums.slice(0, i), target, start);
  }
}
binary search O(log n)
@param {number[]} nums
@param {number} target
@return {number}