Hi there,
I’m stuck on Chunky Monkey even though I feel that I’ve completed the challenge with my own way successfully. The check marks are not turning into green. Below is my code and here is the link of challenge: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey/
Can someone check and point out what’s the issue in my code? I checked in console.log and seems like I’ve completed all the objectives.
function chunkArrayInGroups(arr, size) {
// Break it up.
let newarr = [];
for (let i = 0; i < arr.length; i++) {
if (arr.length > size) {
let sliced = arr.slice(0,size);
newarr.push(sliced);
arr.splice(0, size);
}
}
if (arr.length > 0) {
newarr.push(arr);
}
return newarr[0];
}
console.log(chunkArrayInGroups(["a", "b", "c", "d"], 2));