Chunky Monkey - Can't pass some of the requirements

Tell us what’s happening:

Your code so far


function chunkArrayInGroups(arr, size) {

  // Break it up.
  let newArr = [];
  let i = 0;
  let z = arr.length % size;

  while (i <= arr.length){
     
  newArr.push(arr.slice(i , size))
  i = i + size;
   size = size + size;

  } // while loop ends here

   if (z!= 0){
     newArr.push(arr.slice(-z));
   }
  
  return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)

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

I don’t know why I can’t pass
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)

But chunkArrayInGroups(["a", "b", "c", "d"], 2) works.

  newArr.push(arr.slice(i , size))
  i = i + size;
   size = size + size;

Does this change in the value of size make sense? If you had arr.length = 8 and size = 2, you should end up with, for example, [[a, b], [c, d], [e, f], [g, h]]. Since size represents the desired length of each subarray, you should probably consider keeping it constant.

Thank you.
What I know is that the parameter in slice should be index, no?
arr.slice([begin[, end]])