const tenArray = Array.from(Array(1000000).keys())
// O(log n) - LOGARITHMIC RUNTIME
const binarySearch = (arr, target) => {
let startIndex = 0;
let endIndex = (arr.length) - 1;
while (startIndex <= endIndex) {
let pivot = Math.floor((startIndex + endIndex) / 2);
if (arr[pivot] === target) {
return Found the target: ${target} at index ${pivot}
;
} else if (arr[pivot] < target) {
startIndex = pivot + 1;
} else {
endIndex = pivot - 1;
}
}
return false;
}