Problems

Paginated Response Walker

MediumAPI Integration

Sum items across pages. Input: a JSON array of page responses, each {"items": number[], "nextPage": number|null}. Follow pages in array order until nextPage is null (stop there — later array entries are unreachable). Print two lines: count of items consumed, and their sum.

Input: one JSON array of pages. Output: count, then sum.

Your program reads from stdin and prints to stdout.

Example 1

Input: [{"items":[1,2],"nextPage":2},{"items":[3],"nextPage":null},{"items":[99],"nextPage":null}]

Output: 3 6

Hints

ReactAPIPagination