Tell us what’s happening:
I finally completed the tests, does anyone have any comments or recommendations on my code?
Your code so far
function chunkArrayInGroups(array, n) {
const arraysWithSamelength = Math.floor(array.length / n);
let splitCount = arraysWithSamelength;
if (array.length % n != false) splitCount++ ;
const newArray = [];
for (let i = 1; i <= splitCount; i++) {
if (array.length > n) {
newArray.push(array.splice(0, n))
} else {
newArray.push(array)
}
}
return newArray
}
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4))
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Challenge Information:
Implement the Chunky Monkey Algorithm - Implement the Chunky Monkey Algorithm