Skip to content

Instantly share code, notes, and snippets.

View LukvonStrom's full-sized avatar

Lukas LukvonStrom

View GitHub Profile
@LukvonStrom
LukvonStrom / chunk.js
Created December 31, 2018 16:20 — forked from dragonza/chunk.js
Chunk array
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));
}
/*