title: How can I effectively modify a variable based on the string value of a form question?
body: <p>I'm trying to modify a variable that gets a specific Sheet by Name based on the response to a form question. That is, if 'Fruit' is the answer to a question, the following script should consider the 'Fruits' Sheet as the targetSheet for script execution.</p>
  
  <p>I've tried using a switch with let to redeclare the targetSheet variable in a for loop. </p>
  
  <p>The result is a SyntaxError stating that targetSheet has already been declared</p>
  
  <pre><code>function pickASheet() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var s = ss.getSheetByName('Form');
    var sourceData = s.getDataRange().getValues();
    let targetSheet = ss.getSheetByName('Fruits');
  
    for (var i = 1; i &lt; sourceData.length; i++) {
      var groceryType = sourceData[i][2]; //Column where value will be 'Fruit' or Vegetable'
  
      switch (targetSheet) {
        case groceryType == 'Fruit':
          let targetSheet = ss.getSheetByName('Fruits');
          break;
        case groceryType == 'Vegetable':
          let targetSheet = ss.getSheetByName('Vegetables');
          break;
      }
  }
  }
  </code></pre>
  
  <p>I expect the variable to be redeclared based on the cases, however it seems I am unable to redeclare within the switch.</p>