Tell us what’s happening:
The output is as desired, I have put multiple checks to verify also. But the solution is not accepted.
Your code so far
function chunkArrayInGroups(arr, size) {
// Break it up.
var a = [];
var b = [];
for(var i = 0;i<arr.length;i+=size)
{
if(i+size<arr.length)
a.push(arr.slice(i,i+size));
else
a.push(arr.slice(i,arr.length))
b.push(a);
console.log(a);
a = [];
}
console.log(b);
return b;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey