Skip to content

Instantly share code, notes, and snippets.

@mezerotm
Created September 29, 2020 04:21
Show Gist options
  • Save mezerotm/eb183a87fa6886e920ae31bf990a08ea to your computer and use it in GitHub Desktop.
Save mezerotm/eb183a87fa6886e920ae31bf990a08ea to your computer and use it in GitHub Desktop.
A for loop for pagination
let numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let page = 2
let limit = 5
for(let i = (page * limit - limit); i < numbers.length && i < (page * limit); i++) {
console.log(numbers[i])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment