Basic Algorithm Scripting - Chunky Monkey

Tell us what’s happening:
Hello. please I don’t understand the solutions for the chunky monkey exercise. I find it difficult to connect the workings of the loop and the slice. I hope someone is willing to explain. thanks
ps ignore the comments I made in the code, doesn’t make sense.
the code I have was after checking the solutions but I still don’t get how it works.

  1. List item


Your code so far

function chunkArrayInGroups(arr, size) {
  const newAr = []
    for(let i=0;i<arr.length;i+=size){
  return newAr;

console.log(chunkArrayInGroups(["a", "b", "c", "d"], 2));
// create an emplty array
//loop through arr. regular ffor loop
// create a new empty array
//push the numbers from arr into the new empty array
//based of the size
//push the ne empty array tptonew arr
// return new arr

Your browser information:

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

Challenge: Basic Algorithm Scripting - Chunky Monkey

Link to the challenge:

thank you for your response. Please could you break down the code? I don’t understand how it works. thank you

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.