title: TypeError: Cannot read property "9" from undefined
body: <p>I'm looking to delete rows of a given spreadsheet using the code below, but am receiving the following error: "TypeError: Cannot read property "9" from undefined." When testing the <code>For loop</code> and setting it as <code>i = 20</code>, the code works, but as <code>i = data.length</code>, it results in an error. Any ideas what the problem is? Thanks</p>
  
  <pre><code>function cleanUp() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getActiveSheet();
    var data = sheet.getDataRange().getValues();
  
    for ( var i = data.length ; i &gt; 0; i-- ) {
      if (data[i][9] === 'ERROR' || data[i][9] === 'BOUNCED' || data[i][9] === 'NO_RECIPIENT') {
        sheet.deleteRow(i+1);
      }
    }
  }
  </code></pre>