Implement the Chunky Monkey Algorithm - Implement the Chunky Monkey Algorithm

Tell us what’s happening:

I’m getting the return values that are needed for the tests but for some reason my tests are still failing. I feel like I did what the instructions said though. Am I still doing something wrong?

Your code so far

let twoDimensionalArray = []



function chunkArrayInGroups(array, number) {
  for (let i = 0; i < array.length; i += number) {
    
    console.log("arraylength: " + array.length, "index: " + i, i + number)

twoDimensionalArray.push(array.slice(i, i + number));
}
return twoDimensionalArray;
}

console.log(chunkArrayInGroups(["a", "b", "c", "d"], 2));
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Implement the Chunky Monkey Algorithm - Implement the Chunky Monkey Algorithm

Hi. Move your variable to inside the function. The instructions are looking for 1 function.

1 Like