title: JavaScript - How to Wait / SetTimeOut / Sleep / Delay
body: <p>This again is my Rock Paper Scissors game.</p>
  
  <p>At present state the user can't see what's happening because after being prompted for input(Rock, Paper or Scissors) they are immediately reprompted. </p>
  
  <p>The question is how can I make the program delay such that they at least can read what's going on.</p>
  
  <p>I've read that sleep() does not exist in JavaScript. I'm trying to use setTimeOut however, the setTimeOut is causing the program to not run. </p>
  
  <p><strong>Any ideas on how I can delay the next user input after the first user input. This can be done via any JS solution.</strong> </p>
  
  <p>This is my present code </p>
  
  <pre><code>function playUntil(rounds) {
          var playerWins = 0;
          var computerWins = 0;
          setTimeout(function() {
          while ((playerWins &lt; rounds) &amp;&amp; (computerWins &lt; rounds)) {
            var computerMove = getComputerMove();
            var winner = getWinner(playerMove, computerMove);
            console.log('The player has chosen ' + playerMove + '. The computer has chosen ' + computerMove);
            if (winner === "Player") {
                playerWins += 1; 
            } 
            else if (winner === "Computer") {
                computerWins += 1;
            } 
            if ((playerWins == rounds) || (computerWins == rounds)) {
                console.log("The game is over! The " + winner + " has taken out the game!");
                console.log("The final score was Player - [" + playerWins + "] to Computer - [" + computerWins + "]");
            }
            else {
                console.log(winner + ' takes the round. It is now ' + playerWins + ' to ' + computerWins);
            }
            }
        return [playerWins, computerWins]
      ;},5000);
      }
  </code></pre>