I’m trying to utilise the exec
function within a forEach
loop, as follows:
Instead of writing
var editable = 'Editable Schedule';
var main = 'Main Schedule';
var editableSheet = spreadsheet.getSheetByName(editable);
var mainSheet = spreadsheet.getSheetByName(main);
I was hoping to do something like
var editable = 'Editable Schedule';
var main = 'Main Schedule';
['editable', 'main'].forEach(sheetName => exec('var ' + sheetName + 'Sheet = spreadsheet.getSheetByName("' + eval(sheetName) + '");'));
I’ve replaced exec
with console.log
to check the strings are being formed correctly, and it looks like they are. However, the line does not execute, instead it ets stuck and eventually times out. What am I doing wrong?
5