Skip to content

Instantly share code, notes, and snippets.

@uzorjchibuzor
Created June 15, 2018 12:12
Show Gist options
  • Save uzorjchibuzor/dd2a1f966f92ffed38535649928c340b to your computer and use it in GitHub Desktop.
Save uzorjchibuzor/dd2a1f966f92ffed38535649928c340b to your computer and use it in GitHub Desktop.
function chunkArrayInGroups(arr, size) {
// Break it up.
let chunks = arr.length/size;
let newArray = [];
for (let i = 0; i < chunks ; i++){
let chunkArray= arr.splice(0,size);
newArray.push(chunkArray);
}
return newArray;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment