Ed

Every list view needs pagination. Let's build a reusable pagination utility that handles all the edge cases.

Your Task:

  • Create a paginate(array, page, pageSize) function
  • Return an object with: data (items for current page), page, pageSize, totalItems, totalPages, hasNext, hasPrev
  • Handle edge cases: invalid page numbers, empty arrays
TypeScript Solution
Loading...

Submit your code to see test results