title: Google Apps Script return array values and use them in a javascript function
body: <p>I am trying return an array and use it in a javascript function, but it doesn't seem to work. My Code.gs is as follows:</p>
  
  <pre><code>function doGet() {
    return HtmlService.createHtmlOutputFromFile('test')
    .setSandboxMode(HtmlService.SandboxMode.IFRAME);
  }
  
  function test() {
      var locations = [];
      var ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/13q7pIeMUHll6_5xBUpBavaBqALt9fnFnOIO-Hwy_pFc/edit'),
      sheet = ss.getActiveSheet(),
      range = ss.getRange("D2:D4"),
      values = range.getValues();
      for (var r=1; r&lt;values.length; r++) {
         var row = values[r];
         locations.push(row[0]);
      }
      return locations;
  }
  </code></pre>
  
  <p>The function in my test.html looks as follows:</p>
  
  <pre><code>function hello() {
     google.script.run.test();
  }
  </code></pre>
  
  <p>So I want to pass the array and its contents to the hello function in my test.html. How can I make this work?</p>