Tell us what’s happening:
i know that what’s inside the for loop is wrong cause i’m not getting the expected result but other than that i still can’t of a way of how to fix it
Your code so far
function chunkArrayInGroups(arr, size) {
let newArr = [];
for(let i = 0; i < arr.length; i++){
newArr.push(arr.slice(i, size));
}
return newArr;
}
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3));
the output that i’m getting :
[ [ 0, 1, 2 ], [ 1, 2 ], [ 2 ], , , ]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36
.
Challenge: Chunky Monkey
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey