Created
March 17, 2017 05:00
-
-
Save lachlan-eagling/1064f98f392650d5ec964372b369be10 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
| function chunkArrayInGroups(arr, size) { | |
| var tempArr = []; | |
| var innerTempArr = []; | |
| for(var i = 0; i < arr.length; i++){ | |
| if(innerTempArr.length < size){ | |
| innerTempArr.push(arr[i]); | |
| } else{ | |
| tempArr.push(innerTempArr); | |
| innerTempArr = []; | |
| innerTempArr.push(arr[i]); | |
| } | |
| } | |
| tempArr.push(innerTempArr); | |
| arr = tempArr; | |
| return arr; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment