Chunky Monkey i dont understand commented code

Chunky Monkey i dont understand commented code
0

#1

Tell us what’s happening:

Your code so far

function chunkArrayInGroups(arr, size) {

  var temp = [];
  var result = [];
  

  for(var i = 0; i < arr.length; i++) {
    if (i % size !== size - 1)// i dont understand this line of code please someone explain me
      
      temp.push(arr[i]); //temp ab
    else {
      temp.push(arr[i]);//tempa a
      result.push(temp);// 
      temp = [];//
    }
  }

  if (temp.length !== 0)
     result.push(temp);
     return result;
}
 


chunkArrayInGroups(["a", "b", "c", "d"], 2);
















Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36.

Link to the challenge:


#2

The line checks if the remaider of the current index of arr divided by size is NOT equal to size - 1. If this evaluates to true for the current index of arr, then it will push the current element of arr into the temp array.