Tell us what’s happening:
Hi everyone, i pass this lab with this code. I saw others code and i like their code, which is shorter than mine. (I don’t even think about .slice() )
“fish_99” pass the lab and ask some comments or recommendation on his code. I want to do the same with my code.
Maybe my result is right but my method is wrong.
Your code so far
function chunkArrayInGroups (arr, num) {
let groups = [];
let arrayOfArray = [];
let i = 0;
for (const n in arr) {
if (groups.length < num) {
groups.push(arr[n]);
i++;
} else if (groups.length = num) {
arrayOfArray.push(groups);
groups = [];
groups.push(arr[n]);
i++;
}
}
if (i = arr.length) {
arrayOfArray.push(groups);
}
return arrayOfArray;
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Challenge Information:
Implement the Chunky Monkey Algorithm - Implement the Chunky Monkey Algorithm