title: How to reference a variable dynamically in javascript
body: <p>I am trying to reference a variable dynamically in javascript</p>
  
  <p>The variable I am trying to call is amtgc1# (where # varies from 1-7)</p>
  
  <p>I am using a while statement to loop through, and the value of the counting variable in my while statement corresponds with the last digit of the variable I am trying to call. </p>
  
  <p>For Example:</p>
  
  <pre><code>            var inc=3;
              var step=0;
              while(step &lt; inc){
                  var dataString = dataString + amtgc1#;
                  var step = step+1;
              }
  </code></pre>
  
  <p>Where # is based on the value of the variable "step". How do I go about doing this? Any help is appreciated! Thanks!!</p>