binarySearch iterative implementation in JS complete.