Skip to content

Instantly share code, notes, and snippets.

@lucianobarauna
Last active May 3, 2018 16:39
Show Gist options
  • Save lucianobarauna/c5f3ce0217ebc83084950dbccac11974 to your computer and use it in GitHub Desktop.
Save lucianobarauna/c5f3ce0217ebc83084950dbccac11974 to your computer and use it in GitHub Desktop.
Paginação simples
let lista = ['banana', 'maçã', 'manga', 'caju', 'goiaba']
console.log('minha lista', lista);
let resultShow = (offset, limit) => {
return lista.map((elm, index) => {
if(index >= offset && index < limit + offset) {
return elm
}
}).filter((elm, index) => elm !== undefined)
}
console.log('meu resultado ', resultShow(0, 3)) // ["banana", "maçã", "manga"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment