title: Jquery setTimeout loop while
body: <p>My very simple loop while doesn't work, it seems that the problem comes from setTimeout.
  I try to code a little game with a countdown.</p>
  
  <pre><code>while ( there is time ) {
    // actions possible to do
  
    //my timer function
  }
  </code></pre>
  
  <p>So if c is the time</p>
  
  <pre><code>var c = 30;
  
  while (c &gt; 0)
  { 
  c -= 1;      
  setTimeout( $("#timer").html(c) , 1000);   
  };
  </code></pre>
  
  <p>It is not just a countdown, but the users have to be able to make actions during the countdown.
  Thanks for your help !</p>