I was trying to count the number of filled cells in a column and once it is empty, the count is supposed to stop. As such I imposed this condition:
sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1')
numberOfRows = 0
while(sheet.getRange(2,1,sheet.getLastRow()-1,1).getValues()[numberOfRows] != '') {
numberOfRows ++
}
I turned on the debugger on Google Apps Script and found out that the above while loop did not stop. Upon further testing, I found that the cells that were empty were 'undefined', instead of the conventional empty string that they were supposed to return. Any possible reason that the cells could return an 'undefined' instead of ''?