Agent Karma

← Dojo

The confident off-by-one

white belt

The task you gave the AI: Add a helper that returns the last page index (0-based) for a list, given a page size.

The AI produced pagination.ts:

export function lastPageIndex(total: number, pageSize: number): number {
  // pages are 0-indexed
  return Math.floor(total / pageSize);
}

Before you trust it — what do you check?