title: How to use a loop to test if a variable exists
body: <p>I'm trying to construct the variable name and then test if it exists using a while loop but I think I'm creating it when I test for it so keep getting 'true' and the loop goes infinite.</p>
  
  <pre><code>var1 = "value1"
  var2 = "value2"
  var3 = "value3"
  
  var i = 3
  Logger.log(('value'+i)==true)
  var i = 4
  Logger.log(('value'+i)==true)
  
  /*
  var i = 1;
  while (("value"+i) != null) {
  Logger.log("value"+i)
  i++;
  }
  */
  </code></pre>
  
  <p>When I build the loop I want value4 to not exist and stop the loop but it doesn't. Because I've just created it's string I suppose, so how should I be formatting the test? First question here and I have searched but the 'construction' part seems to complicate things. Thanks.</p>