Octagram Labs
JavaScriptData StructuresReact
Sign in
← Back to problems

Page Numbers

Rendering Listsmedium

Course · Section 11: Working With Arrays · Lecture 157: The map Method

Implement `pageNumbers(total, size)` returning an array `[1, 2, ...]` of page numbers needed to show `total` items `size` per page.

Sample tests

Input: pageNumbers(10, 3)
Output: [1,2,3,4]
Input: pageNumbers(6, 3)
Output: [1,2]

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Using floor instead of ceil, which drops the last partial page.

Learning resources

  • React: Rendering Lists
Approach & explanation (try first)

Math.ceil(total / size) is how many pages you need; Array.from({length: count}, (_, i) => i + 1) produces the 1-based page numbers.

Loading...
⌘/Ctrl + Enter

Run your code to see results.