I am relatively new to Google Script and I am currently working on a piece of code that is giving me some trouble. My goal is to have the program loop through a range of cells in a spreadsheet, printing them out until it reaches the last row. Despite trying to use .getLastRow() function within the for loop or creating a separate variable, I have not been successful. (Some sections of the code are repetitive and unrelated to the issue at hand so they can be disregarded.)
function myFunction()
{
var spreadSheet = SpreadsheetApp.openById("1F4zEJXKN3iobK8b89Ub94dd77Tdk70H0X8aFCSCmvRs");
var activeSheetOne = spreadSheet.getSheetByName("New Family Responses");
var activeSheetTwo = spreadSheet.getSheetByName("Existing Family Responses");
var readingGender = activeSheetOne.getRange("E3:E").getValues();
var lastRow = readingGender.getLastRow();
var loopVar = 0;
for (var i=0; i < lastRow; i++) {
Logger.log(readingGender[loopVar][0]);
loopVar = loopVar + 1;
}
}