1function binarySearchIndex (array, target, low = 0, high = array.length - 1) {
2 if (low > high) {
3 return -1
4 }
5 const midPoint = Math.floor((low + high) / 2)
6
7 if (target < array[midPoint]) {
8 return binarySearchIndex(array, target, low, midPoint - 1)
9 } else if (target > array[midPoint]) {
10 return binarySearchIndex(array, target, midPoint + 1, high)
11 } else {
12 return midPoint
13 }
14}