Chunky Monkey - What's wrong with my solution?

Hi there,

I’m stuck on Chunky Monkey even though I feel that I’ve completed the challenge with my own way successfully. The check marks are not turning into green. Below is my code and here is the link of challenge: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey/

Can someone check and point out what’s the issue in my code? I checked in console.log and seems like I’ve completed all the objectives.

function chunkArrayInGroups(arr, size) {
  // Break it up.

  let newarr = [];

  for (let i = 0; i < arr.length; i++) {
    if (arr.length > size) {
       let sliced = arr.slice(0,size);
       newarr.push(sliced);
       arr.splice(0, size); 
    }
  }

  if (arr.length > 0) {
    newarr.push(arr);
  }
  return newarr[0];
}

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

Okay, I figured out what’s the issue and managed to solve the challenge. The new solution is:

function chunkArrayInGroups(arr, size) {
  // Break it up.

  let newarr = [];

  //incrementing i with splitting size
  for (let i = 0; i < arr.length; i+size) {
    //copying the elements in sliced array
    let sliced = arr.slice(0, size);
    //removing the copied elements from array so that next iteration would perform correctly
    arr.splice(0, size);
    //pushing the sliced array into the array which we will return
    newarr.push(sliced);
  }
  return newarr;
}

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