title: Can't manage to sleep inside a loop
body: <p>I  want to pause <code>1 second</code> for every time it loops, it is usually easy to do similar pauses on other cases, but when working with loops, it seems it get harder:</p>
  
  <pre><code>for (var i=0 ; i &lt; 10 ; i++) {
      document.write (i + "&lt;br&gt;");
      // I want to wait 1 second here
  }
  </code></pre>
  
  <p>This is one example of my thousands failed attempts:</p>
  
  <pre><code>function writeMsg (index) {
      document.write (index + "&lt;br&gt;");
  }
  
  for (var i=0 ; i &lt; 10 ; i++) {
      setTimeout (writeMsg(i), 1000);
  }
  </code></pre>
  
  <p>Any ideas of how to get this to work?</p>