title: Trying a infinite loop on JavaScript
body: <p>I am trying to do a infinite loop, but it only works if I include an 'alert' on it. My code looks like this:</p>
  
  <pre><code>while( tocontinue ){
    // Some code
    alert('Accept to continue');
  }
  </code></pre>
  
  <p>On this way, the user has to click to hide the alerts (for example, on Chrome), and then the loop continues correctly by itself. I need to implement this without any alert. I also tried this:</p>
  
  <pre><code>while( tocontinue ){
    // Some code
    tocontinue = false;
    setTimeout(function(){tocontinue=true},500);
  }
  </code></pre>
  
  <p>And with "window.setTimeout" too, and without the word "function(){}", but it doesn't work. I tried everything: some implementations on JavaScript of a sleep() function, calling the function each <em>X</em> time with setInterval, answers 1 and 3 on <a href="https://stackoverflow.com/questions/5835126/javascript-infinite-loop">this post</a>... :/</p>
  
  <p>Thank you very much for your time.</p>