Binary Search Question Leetcode Javascript