title: Javascript - display incrementing number every second
body: <p>I am trying to do something where I display a different incremented number every second but I just can't get the setInterval thing right.</p>
  
  <p>Here is what I have</p>
  
  <pre><code>function counter() {
  
      var i = 0;
      while ( i &lt; 100 ) {
          // This block will be executed 100 times.
          setInterval(console.log( 'Currently at ' + i ), 1000);
          i++; // Increment i
      }
  
  } // End
  </code></pre>
  
  <p>But what I get is the console.log firing a 100 times, then repeating.</p>
  
  <p>Thanks for all the help.</p>
  
  <p>Mike</p>