Created
May 18, 2018 20:10
-
-
Save mohammad-haji/d1706f5c63d10a53e277f88fd52ab01c 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
/** | |
* chunk array into specific chunks :) | |
* @param arr | |
* @param len | |
* @returns {Array} | |
*/ | |
function chunkArray(arr, len) { | |
if (!Array.isArray(arr)) return []; | |
let chunks = [], | |
i = 0, | |
arrayLen = arr.length; | |
while (i < n) { | |
chunks.push(arr.slice(i, i += len)); | |
} | |
return chunks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment