Hi everyone, I’m wondering if anyone can tell me why my code isn’t passing any of the tests?
So I tested it on the chrome console and it looks like it achieves the desired result.
function chunkArrayInGroups(arr, size) {
let spliced;
let finalArr = [];
while (arr.length > size) {
spliced = arr.splice(0, size);
finalArr.push([]);
finalArr[finalArr.length-1].push(spliced);
}
if (arr.length <= size) {
finalArr.push([]);
finalArr[finalArr.length-1].push(arr);
}
return finalArr;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);
This is the challenge:
Wait: so do you still have a problem?
No, I figured out I was doing this all wrong! Sorry.
Then, you should click your own reply as the “solution.”
Ok so now that I feel like I’ve understood what I should have done I can’t pass any of the tests either, even though it seems to work on the chrome dev tools console 
I’m gonna update the OP.
function chunkArrayInGroups(arr, size) {
let spliced;
let finalArr = [];
while (arr.length > size) {
spliced = arr.splice(0, size);
finalArr.push([]);
finalArr[finalArr.length-1].push(spliced);
}
if (arr.length <= size) {
finalArr.push([]);
finalArr[finalArr.length-1].push(arr);
}
return finalArr;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);
Ok, I figured it out, looks like I was adding an additional array level by pushing [] into the final array every time… It made sense in my head somehow xD