Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2015 06:41
Show Gist options
  • Save anonymous/80d2a104454781fc6acb to your computer and use it in GitHub Desktop.
Save anonymous/80d2a104454781fc6acb to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/kkas 's solution for Bonfire: Chunky Monkey
// Bonfire: Chunky Monkey
// Author: @kkas
// 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 i, len = arr.length, newAry = [];
for(i = 0; i < len; i += size) {
newAry.push(arr.slice(i, i + size));
}
return newAry;
}
chunk(["a", "b", "c", "d"], 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment