HomeChallengesRepsProblemsLeaderboardTake a challenge

Pagination

One function you will write in every job you ever have. Get the edges right.

Beginner12 min on the clock5 graded checks · 100 pointsJavaScript + TypeScript
Graded by running your code against real cases.

What you build

  • paginate(items, page, pageSize) returns the slice plus its metadata
  • data, page, pageSize, totalItems, totalPages
  • hasNextPage and hasPreviousPage
  • The last page may be partial
  • A page beyond the end must not crash

Done means

Every field is correct on the first page, a middle page, the last page and beyond it.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. The right slice comes back+25Pagination
  2. totalItems and totalPages are right+20Pagination
  3. hasNextPage and hasPreviousPage are right+25Pagination
  4. The last page may be partial+15Pagination
  5. A page past the end does not crash+15Pagination

What it teaches

The rest of JavaScript + TypeScript