Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save afaqahmedkhan/27d014d568b6eb13270f7592efad6850 to your computer and use it in GitHub Desktop.
Save afaqahmedkhan/27d014d568b6eb13270f7592efad6850 to your computer and use it in GitHub Desktop.
Basic Algorithm Scripting: Chunky Monkey
function chunkArrayInGroups(arr, size) {
let len = arr.length;
let arr2 = [];
for(let i =0;i<arr.length;i=i+size){
arr2.push(arr.slice(i,i+size));
}
return arr2;
}
console.log(chunkArrayInGroups(["a", "b", "c", "d"], 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment