```typescript
/** The index of target in a sorted array, or -1 if not found. */
export function binarySearch(items: readonly number[], target: number): number {
  let low = 0;
  let high = items.length; // Modified from high = items.length - 1 to include the last element

  while (low < high) {
    const mid = Math.floor((low + high) / 2);
    if (items[mid] === target) {
      return mid;
    }
    if (items[mid] < target) {
      low = mid + 1; // Modified from low = mid to low = mid + 1
    } else {
      high = mid; // Modified from high = mid - 1 to high = mid
    }
  }

  return items[low] === target ? low : -1; // Check if the last element is the target and adjust accordingly
}
```