Last active
August 17, 2016 05:16
-
-
Save thinsoldier/0ba8be1e6534bc6002dc9eb6838d73bd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// https://www.freecodecamp.com/challenges/chunky-monkey/ | |
function chunkArrayInGroups(arr, size) { | |
// avoid infinite loop | |
if( arr.length === 0 || size === 0) | |
{ return false; } | |
var chunkedList = []; | |
for ( var i=0; i < arr.length; i += size) | |
{ | |
var temp = arr.slice(i, i+size); | |
chunkedList.push(temp); | |
} | |
return chunkedList; | |
} | |
chunkArrayInGroups(["a", "b", "c", "d"], 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment