title: Comparing array values in Google Apps script
body: <p>I feel that the following two functions should produce the same result, but function <code>bob()</code> never finds <code>name1</code> equal to <code>name2</code>, even though the names in those cells are indeed equal.</p>
  
  <p>The function <code>bob2()</code> works fine, but I'm trying to speed things up by using arrays.</p>
  
  <pre><code>function bob() 
  {
    var ss = SpreadsheetApp.getActiveSheet();
    var name1 ;
    var name2 ;
    var AthName = ss.getRange(1,2,30).getValues();
  
    for (var xx=1; xx&lt;30 ;xx++)
    {
      name1=AthName[xx]
      name2=AthName[xx+1]
    //name1 never equals name2 here. 
      if (name1==name2) ss.getRange(xx,10).setValue(name2);
    }
  }
  
  
  function bob2() 
  {
    var ss = SpreadsheetApp.getActiveSheet();
    var name1 ;
    var name2 ;
  
    for (var xx=1; xx&lt;30 ;xx++)
    {
      name1 = ss.getRange(xx,2).getValue();
      name2 = ss.getRange(xx+1,2).getValue();
    //name1 does equal name2 here as expected.
      if (name1==name2) ss.getRange(4+xx,10).setValue(name2);
    }
  }
  </code></pre>
  
  <p>What's wrong with <code>bob()</code>?</p>