title: passing arguments in google apps script
body: <p>I am trying to simplify my google apps script code and increase its readability. To this end, instead of calling <code>setActiveSheet()</code> function each time I want to activate a new sheet in my code, I decided to write a function that does the job and just call that function and include the name of the sheet as an argument like this:</p>
  
  <pre><code>function setSheet (sheetName) {
    var sheetName;
    var spreadsheet = SpreadsheetApp.getActive();
    spreadsheet.setActiveSheet(spreadsheet.getSheetByName(sheetName));
    var sheet = spreadsheet.getActiveSheet();
  };
  </code></pre>
  
  <p>Then for example if I want to activate the sheet named "Students", I would write the following simple code:</p>
  
  <pre><code>setSheet("Students");
  </code></pre>
  
  <p>The above code won't work. Any help?</p>