title: javascript: var i is not defined? (clearly defined)
body: <p><strong>WHAT I WANT TO HAPPEN</strong></p>
  
  <p>So what I want to happen is function partA() to click button [z] every 2 seconds. The button that is being clicked should change, because the script is a looping script, so for instance. The first loop, it would click button 1, then button 2, then button 3, because <strong>var z = 1 + i++</strong>. Is this possible? z is supposed to equal the number 1, plus the loop number. This should loop as long as variable i is less than 50.</p>
  
  <p><strong>WHAT IS HAPPENING</strong></p>
  
  <p>It works properly, looping and all, if I test the script <strong>without</strong> variable z. However, without variable z, I have to manually change the number that would equal z, which is painstaking, and annoying.</p>
  
  <pre><code>var z = 1 + i++
  for(i=0;i&lt;50;i++) {
    setInterval(partA, 2000);
    function partA() {
      buttons = document.getElementsByTagName('button');
      document.getElementsByTagName('button')[z].click();
    }
  }
  </code></pre>
  
  <p>Should i++ be defined another way? The error I'm getting when running the script in console is:</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: i is not defined (...)</p>
    
    <p>at :2:13</p>
    
    <p>at Object.InjectedScript._evaluateOn (:878:140)</p>
    
    <p>at Object.InjectedScript._evaluateAndWrap (:811:34)</p>
    
    <p>at Object.InjectedScript.evaluate (:667:21)</p>
  </blockquote>