function binarySearch(arr, target){
let min = 0;
let max = arr.length - 1;
let guess;
while(min <= max) {
// min, max의 가운데 값 초기화
guess = Math.floor((min + max) / 2);
if (arr[guess] === target) {
return guess;
} else if (arr[guess] < target) {
min = guess + 1;
} else {
max = guess - 1;
}
}
return -1;
}
binarySearch([2, 3, 5, 7, 11, 13, 17, 19], 5); // 2