title: Combining arrays to use in Google Sheets
body: <p>I'm having some trouble combining arrays into one array and then flipping it with the code below. The goal is to set an array of values in one column of a spreadsheet. After the titleArray function, I would like to have an array spread across multiple columns on one row. Then, using a function I found in another Stack Overflow thread (<a href="https://stackoverflow.com/questions/16621470/google-spreadsheet-script-how-to-transpose-rotate-multi-dimensional-array">Google Spreadsheet Script - How to Transpose / Rotate Multi-dimensional Array?</a>), I want to flip the array so it is spread across multiple rows on one column. The current code is returning an array for each element in array1 all inside of another array. Then, the transposeArray function is combining values from each array, 1 with 1, 2 with 2, and so on. Can anyone spot what I'm doing wrong here?  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var titleArray = function(){
      var output = [];
      for(i=0; i &lt; array1.length; i++){
            if(array1[i].length &gt; 0){   
              var titles = ["",array1[i] + " Data"].concat(array2, array3, array4, array5, array6, array7);
              output.push(titles);
            }
          }
          return(output);
        }
      }
  
        
      function transposeArray(array){
       var result = [];
       for (var col = 0; col &lt; array[0].length; col++) { // Loop over array cols
         result[col] = [];
          for (var row = 0; row &lt; array.length; row++) { // Loop over array rows
            result[col][row] = array[row][col]; // Rotate
           }
          }
         return result;
        }
      transposeArray(titleArray);</code></pre>
  </div>
  </div>
  </p>