title: setInterval within a for-loop not working
body: <p>What I want is an infinite loop that alerts 1, 2, 3, 1, 2, 3, ... with an interval of 2000 milliseconds. But it's not working. The console's not showing any error though. What's the problem here?</p>
  
  <pre><code>for (i = 1; i &lt;= 3; i++) {
      setInterval(function() {
          alert(i);
      }, 2000);
  
      if (i == 3) {
          i = 0;
      }
  }
  </code></pre>