IntermediateJavaScript

Implement binary search

Implement a binary search algorithm on a sorted array.

Examples

Input: binarySearch([1, 3, 5, 7, 9], 5)

Output: 2

Your Solution

Output

Click 'Run Code' to see the output