title: TypeError: Cannot read property "length" from undefined in Google apps script
body: <p>Hi i have a column G2: G in googlesheet named 'Rank sheet' with storename like
  <code>column G
   storeA
   storeB
   storeC
   storeA
   storeA
   storeD</code></p>
  
  <p>I want to create a function name 'remove' (google apps script) to delete row of duplicated names, but when i run it, gsheet say :"TypeError: Cannot read property "length" from undefined." Can anyone can help me to fix it or help with your code. Thank so much
  My code is:</p>
  
  <pre><code>function remove() {
    var range2 = rankSheet.getRange("G2:G");
    var values2 = range2.getValues();
    for (var n = 0; n &lt; values2.length; n++) {
  if(values2[n] == values2[n+1]) {      
    var outarray = []
    outarray.push(n+2)
    Logger.log(outarray)
    }
  }
    for (var m = 0; m &lt;= outarray.length - 1; m++) {
    rankSheet.deleteRow(outarray[m]);
    }
  }
  </code></pre>