title: javascript - do while loop setTimeout
body: <p>I have read many topics about <code>setTimeout</code> but still i have a problem in understanding how can i implement this function to my loop. 
  I'll try to show you what I mean.</p>
  
  <pre><code>function RandomHit(anyArray)
  {    
      var turechange = false;
      do{
          setTimeout(function(){
              var random = Math.floor(Math.random()*2);
              if(random===0)
              {
                  turechange = true;
                  console.log(random);
              }
              if(random===1)
              {
                  console.log(random);    
              }
          }, 2000);
      }while(!turechange);
  }
  </code></pre>
  
  <p>Every time when the loop goes again, i try slow down code for a 2000 ms. But this doesn't work.</p>