Skip to content

Instantly share code, notes, and snippets.

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