What Went Wrong?: Chunky Monkey

Your code so far


function chunkArrayInGroups(arr, size) {
  // Break it up.
  let globalArray = [];
  while(arr.length !== size){
    let localArray = [];
    localArray.push(arr.splice(size, size));
    globalArray.push(localArray);
  }
  globalArray.unshift(arr);
  console.log(globalArray)
}

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

Your browser information:

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

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

Hey @SharonNg98,

Taking this test case as example,
The function should return:

[["a","b"], ["c","d"], ["e","f"]]

While your function returns:

[["a","b"], [["c","d"]], [["e","f"]] ]

See if you can find out the reason for difference.

Hint: It has something to do with this line of code:

Let me know if this helps.