Created
June 15, 2018 12:12
-
-
Save uzorjchibuzor/dd2a1f966f92ffed38535649928c340b 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
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