input: Write a function to perform a binary search on a sorted array.
  assert binarySearch([1, 2, 3, 4, 5], 3) == 2
  assert binarySearch([10, 20, 30, 40, 50], 10) == 0
  assert binarySearch([10, 20, 30, 40, 50], 60) == -1
  assert binarySearch([], 5) == -1
  assert binarySearch([5], 5) == 0
output: def binarySearch(arr, target):
      left, right = 0, arr.length - 1
      while left <= right:
          mid = (left + right) // 2
          if arr[mid] == target:
              return mid
          elif arr[mid] < target:
              left = mid + 1
          else:
              right = mid - 1
      return -1