A Pen by Afaq Ahmed Khan on CodePen.
Created
November 17, 2018 12:25
-
-
Save afaqahmedkhan/27d014d568b6eb13270f7592efad6850 to your computer and use it in GitHub Desktop.
Basic Algorithm Scripting: Chunky Monkey
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
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