Chunky Monkey does not recognize my solution

Chunky Monkey does not recognize my solution
0

#1

Tell us what’s happening:
Hi, I solved Chunky Monkey challenge (all answers of my program match required answers)
But the system does not recognize my solution as good one.
Please help
Here is pic how it looks like

Your code so far


function chunkArrayInGroups(arr, size) {
  
  if(arr.length>size){
    arrnew.push(arr.slice(0,size));
    arr = arr.slice(size,arr.length);
    return chunkArrayInGroups(arr, size);
  }
  
  arrnew.push(arr);
  
  return arrnew;
  
}


chunkArrayInGroups(["a", "b", "c", "d"], 2);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36.

Link to the challenge:


#2

You have something called arrnew, but you did not declare it or initialize (assign) it anything. The push function works with arrays, so try declaring arrnew as an empty array.

This will not solve the challenge, because you still have some logic issues, but at least will get you past this current error.


#3

Thank you, Randell!
If you check screenshot I shared above, you can see I do declare arrnew empty array at the very beginning of the file.
That’s why it is strange.


#4

I was not going by the screenshot, I was going by what showed below “Your code so far” above.

You will not be able to pass the FCC tests putting arrnew outside the function. The tests are run consecutively, so arrnew will keep getting larger and larger as each test runs, because it will retain its last value of the previous function call (test case).


#5

Ok. Thank you. Clear now