Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- function partition(list, size) {
- const groups = []
- let currentGroup = []
- for (let index = 0; index < list.length; index++) {
- currentGroup.push(list[index])
- if (currentGroup.length >= size || index === list.length - 1) {
- groups.push(currentGroup)
- currentGroup = []
- }
- }
- return groups
- }
- module.exports = partition
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement