Chunky Monkey not passing tests

Chunky Monkey not passing tests
0

#1

Tell us what’s happening:
Hello. Can someone either give me a hint or tell me what’s wrong with this code? I come up with the correct results, but it is not passing any of the tests.

Your code so far

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var count = 0;
  for (var i = 0; i < arr.length; i+=size) {
    newArray.push(arr.slice(count, count+size));
    count += size;
  }
  return newArray;
}
chunkArrayInGroups(["a", "b", "c", "d", "e"], 2);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:


#2

Have you solved this yet? You forgot to declare a newArray variable.


#3

I think I goofed when I did copy/paste. I do have var newArray=[]; on line 1. Any other ideas? Thanks!


#4

I moved my newArray variable from outside the function to inside the function, and it passed. Thanks @kevcomedia for taking the time to look at my code.