title: Return 2D array from Google Apps Script
body: <p>I'm trying to break a long array into a multiple column (2D) array in my Google Sheets. Here's my function below:</p>
  
  <pre class="lang-js prettyprint-override"><code>function SPLITARR(data, colNum) {
    if (colNum &lt;= 1) {
      return data;
    }
  
    var res = [];
    var col = [];
    var i = 0;
  
    data.forEach(function(el) {
      if (i &gt;= colNum) {
        res.push(col);
        col = [];
        i = 0;
      }
  
      col.push(el);
      i++;
    });
  
    res.push(col);
    Logger.log(res); // Debugging purposes.
    return res;
  }
  </code></pre>
  
  <p>Sending the following test data:</p>
  
  <pre><code>var test = ['alex', 'alecia', 'conrad', 'keenan', 'Beebo', 'jacques', 'jeremy', 'susan', 'jay']
  SPLITARR(test, 2);
  </code></pre>
  
  <p>The result that is being logged seems correct:</p>
  
  <pre><code>[[alex, alecia], [conrad, keenan], [Beebo, jacques], [jeremy, susan], [jay]]
  </code></pre>
  
  <p>But on Google sheets, nothing shows. The formula displays no errors and fills the expected number of cells, but it fills them with nothing. </p>
  
  <p><strong>Is there a specific format that 2D arrays need to adhere to in order to be displayed properly?</strong></p>