function binary_search(array, key){ let low = 0 let high = array.length - 1 while(low<=high){ let mid = parseInt((high+low)/2) if(array[mid]===key){ return mid } else if(array[mid]<key) { low = mid + 1 } else if(array[mid]>key) { high = mid - 1 } } return -1 }