title: JavaScript setTimeout in a For loop issue
body: <p>My issue is I am trying to increment the timeout time by the iteration value and time it by 1000. for example if the increment value is 5 it will be 5*1000 on the timeout.</p>
  
  <p>I have tried various ways the first being -> </p>
  
  <pre><code>var textValue = 10;
  function doSetTimeout(i) {
     setTimeout(function() { console.log(i); }, i * 1000);
  }
  
  for(var i = 1; i &lt;= textValue; i++){
       doSetTimeout(i); 
   }     
  </code></pre>
  
  <p>I also tried this -></p>
  
  <pre><code>var textValue = 10;
   for(var i = 1; i &lt;= textValue; i++){
       (function () {
           var j = i;         
           setTimeout(function timer() {
                 console.log(j);
                },j*1000);
        })();     
   }
  </code></pre>
  
  <p>All I get on both is that the timeout is always set to 1000 ms even though the variable is being set correctly each time.</p>
  
  <p>Any help would be appreciated.</p>