Hi, I’m doing chunky monkey.
“Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.”
function chunkArrayInGroups(arr, size) {
var a = arr;
var b = [];
for ( var i = arr.length; i > 0; i - size) {
b.push(a.splice(-size));
}
return b.pop();
}
I know there’s an infinite loop, I believe it has something to do with (i - size), but I can’t figure it out…
If anyone could help, it would be very appreciated, thanks.
Also, when I relocate “return b.pop()” above the curly braces, it sends out half of what i want, but won’t do the rest?