Hey All,
I’ve done a lot of weird music algorithm coding, and from that have developed an affinity to the % operator. I used it in Chunky Monkey, and I didn’t see anyone else solving it that way. Does anyone have any advice regarding its efficiency/bugginess/style?
function chunkArrayInGroups(arr, size) {
// Break it up.
var chunks = [];
for(var i = 0; i < arr.length; i++){
if(i%size == 0) chunks.push(arr.slice(i,i+size));
}
return chunks;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);