Created
September 9, 2020 01:31
-
-
Save alebian/31197a3aacefdff1aecbe6f26d4b31fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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