Skip to content

Instantly share code, notes, and snippets.

@mtroiani
Created December 12, 2015 02:11
Show Gist options
  • Save mtroiani/028ca90e075e8025e1af to your computer and use it in GitHub Desktop.
Save mtroiani/028ca90e075e8025e1af to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mtroiani 's solution for Bonfire: Chunky Monkey
// Bonfire: Chunky Monkey
// Author: @mtroiani
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, size) {
var chunkedArr = [];
var n = 0;
for (var i = 0; i < arr.length; i += size) {
chunkedArr.push(arr.slice(i, i + size));
}
return chunkedArr;
}
chunk(["a", "b", "c", "d"], 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment