[Help needed] Chunky Monkey

I’m stumped. Below is my code, but it says that there is an infinite loop in line 5. Can someone sort of walk me through this / provide and help or feedback?


function chunkArrayInGroups(arr, size) {
// Break it up.
var ans = [];
for (i=0;i<arr.length;i+size) {
return ans;

i+size doesn’t actually do anything to i. Also, you want the var keyword in the first clause.

for(var i = 0; i < arr.length; i += size)

ah gotcha, thanks!!! I made the changes but its still not working, any other hints / clues to where the issue is? thanks again for your help

You do this - arr.slice(i,size). Here i is changing at each iteration and size does not. But if you read about the slice method - you’ll see how it’s written arr.slice([begin[, end]]). So, in your case begin point is changing, but end point is always the same…

1 Like

aha!! Thanks so much! Got it all figured out now! I wasn’t fully udnerstanding how slice works… I thought the end variable is how many places to the right from the start variable the end is, but its a static place. Thanks so much for your help