title: Splitting an array into multi dimensional array chunks
body: <p>I was supposed to </p>
  
  <blockquote>
    <p>"Write a function that splits an array (first argument) into groups
    the length of size (second argument) and return them as a
    two-dimensional array."</p>
  </blockquote>
  
  <p>Unfortunately, I could not figure it out thus I checked the code solution. The problem is I don't understand <em>why</em> this conditional statement is used: <code>if (a % size !== size - 1)</code></p>
  
  <pre><code>function chunkArrayInGroups(arr, size) {
  
        var temp = [];
        var result = [];
  
        for (var a = 0; a &lt; arr.length; a++) {
          if (a % size !== size - 1)
            temp.push(arr[a]);
          else {
            temp.push(arr[a]);
            result.push(temp);
            temp = [];
          }
        }
  
        if (temp.length !== 0)
          result.push(temp);
        return result;
      }
  </code></pre>