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 chunk(array, size) { | |
if (!array) return []; | |
const firstChunk = array.slice(0, size); // create the first chunk of the given array | |
if (!firstChunk.length) { | |
return array; // this is the base case to terminal the recursive | |
} | |
return [firstChunk].concat(chunk(array.slice(size, array.length), size)); | |
} | |
/* |