🙌 OpenHands
← All demos
Simulated demo
You
Fix the off-by-one error in the pagination logic in routes.ts
OpenHands
Found it — the loop was using
<=
instead of
<
. Reading routes.ts…
OpenHands
Applied the fix and ran the test suite — all 42 tests pass. See the diff on the right.
Send
Changes
Terminal
src/routes.ts
for (let i = 0; i < items.length; i++) {
const page = Math.floor(i / pageSize);
- if (page <= maxPages) {
+ if (page < maxPages) {
results[page].push(items[i]);
}
}
$ npm test
PASS src/routes.test.ts
✓ paginates items correctly (42 tests)
Test Suites: 1 passed, 1 total
Tests: 42 passed, 42 total