The problem was to write a function that splits an array (first argument) into groups the length of size
(second argument) and returns them as a two-dimensional array.
My code is
function chunkArrayInGroups(arr, size) {
let newArray = [];
for(let i = 0; i < arr.length; i += size){
newArray.push([arr.slice(i, i + size)]);
}
return newArray;
}
I checked on the console and it was correct somehow. I can’t see where I went wrong. Please help