1function paginate(array, page_size, page_number) {
2 // human-readable page numbers usually start with 1, so we reduce 1 in the first argument
3 return array.slice((page_number - 1) * page_size, page_number * page_size);
4}
5
6console.log(paginate([1, 2, 3, 4, 5, 6], 2, 2));
7console.log(paginate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 4, 1));