function lockCells(spreadsheet, cell, rangeToLock) {
// Get the value of the specified cell
var cellValue = spreadsheet.getRange(cell).getValue();
// If the cell value is true, lock the specified range of cells
if (cellValue === true) {
spreadsheet.getRange(rangeToLock).setLocked(true);
// Call the lockCells function to lock cells A1:A5 if cell B1 is set to TRUE
lockCells(SpreadsheetApp.getActiveSheet(),"B1","A1:A5");
}
}
TypeError: Cannot read properties of undefined (reading 'getRange') lockCells @ LockCells.gs:3
How to correct the error.