Chunky Monkey doesn't accept the code that works

Why isn’t this code accepted? It works just fine.

  **My code**

function chunkArrayInGroups(arr, size) {
console.clear();
var newArr = [];
var smallArr = [];

for (let j = 0; j < arr.length; j = j + size) {
  smallArr = [];
  for (let i = 0; i < size; i = i + 1) {
    if ((j + i) > arr.length - 1) {
      break;
    }
    smallArr.push(arr[j+i]);
  }
  //console.log(smallArr);
  newArr.push(smallArr);
} 

console.log(newArr);

return arr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
  **Your browser information:**

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

Challenge: Chunky Monkey

Link to the challenge:

The reason why you assume it works is, because you log “newArr” to the console at the end of the function. But now double check what your function is actually returning :wink:

1 Like

facepalm. THIS IS IT?! I’ve spent 2 hours trying to figure it out!! Thank you.

1 Like