title: google app script compare value to array values
body: <p>I've got this working code:</p>
  
  <pre><code>function hUpdate() {
    var ss = SpreadsheetApp.getActiveSheet();
    var hRowNum = ss.getLastRow();   
  
    var hNew = ss.getRange(hRowNum,3).getValue();   // value being compared
  
    var hCompare = ss.getRange(hRowNum-1,3).getValue();
    if (hNew == hCompare)
    {hNew = 'same';}
    else
    {hNew = 'different';}
  
    return hNew;
  }
  </code></pre>
  
  <p>What I really want to do is compare <code>hNew</code> with all values in previous rows of the same column. I know I have to use an array but I'm stuck with the actual coding.</p>