I am working through a javascript problem that asks me to:
Write a function that splits an array (first argument) into groups the length of size (second argument) an
function chunk(arr, size) { var newArr = []; // x is less than or equals arr.length. for(var x = 0; x <= arr.length; x++){ newArr.push(arr.splice(0, size)); } if (arr.length){ newArr.push(arr); } return newArr; } chunk(['a', 'b', 'c', 'd'], 2);