Chunky Monkey simple adding solution

Tell us what’s happening:

I have written the code for Chunky Monkey JS algorithmic exercise and I believe it should work, but it doesn’t!

Your code so far

function chunkArrayInGroups(arr, size) {
  let res = [[]]
  for (let i = 0; i < arr.length; i++) {
    if (i == size)
      res.push([])
    res[res.length - 1].push(arr[i])
  }
  return res
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey

I am blind. :neutral_face:

This is the correct solution:

function chunkArrayInGroups(arr, size) {
  let res = []
  for (let i = 0; i < arr.length; i++) {
    if (i % size == 0)
      res.push([])
    res[res.length - 1].push(arr[i])
  }
  return res
}