user
Implement a binary search algorithm.

arr: [1, 2, 4, 6, 8, 10, 11, 15], x: 8


assistant
let start = 0 
let end = arr.length -1
while (start <= end) {
    let mid = Math.floor((start + end)/2)
    if (arr[mid] == x) {
        return mid 
    }
    else if (arr[mid] < x) {
        start = mid + 1
    }
    else {
        end = mid - 1
    }
}
return -1