Chunky Monkey Doubt

Tell us what’s happening:
The output is as desired, I have put multiple checks to verify also. But the solution is not accepted.

Your code so far


function chunkArrayInGroups(arr, size) {
  // Break it up.
  var a = [];
  var b = [];
  for(var i = 0;i<arr.length;i+=size)
  {
    if(i+size<arr.length)
    a.push(arr.slice(i,i+size));
    else
    a.push(arr.slice(i,arr.length))
    b.push(a);
    console.log(a);
    a = []; 
  }
  console.log(b);
  return b;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey

slice returns an array
Which you are then pushing in an array, and then in an array

I suggest you use the browser console to check the values, or you use console.log(JSON.stringify(..) to check

Anyway, you don’t need the if/else statement as:

If end is greater than the length of the sequence, slice extracts through to the end of the sequence ( arr.length ).