Skip to content

Instantly share code, notes, and snippets.

@alebian
Created September 9, 2020 01:31
Show Gist options
  • Save alebian/31197a3aacefdff1aecbe6f26d4b31fd to your computer and use it in GitHub Desktop.
Save alebian/31197a3aacefdff1aecbe6f26d4b31fd to your computer and use it in GitHub Desktop.
const sublistsOf = (list, number) => {
const result = [];
let aux = [];
list.forEach(el => {
if (aux.length >= number) {
result.push(aux);
aux = [];
}
aux.push(el);
});
if (aux.length > 0) {
result.push(aux);
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment