Created
November 23, 2015 04:49
-
-
Save dmidlo/a2843b388a23411bde37 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 chunkArray(arr, size) { | |
// creates a matrix of N elements from a single array | |
var resultArray = []; | |
for (var i = 0; i < arr.length; i += size) { | |
resultArray.push(arr.slice(i, i + size)); | |
} | |
return (resultArray); | |
} | |
chunkArray(["a", "b", "c", "d", "e"], 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment