Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript code freezes screen for set amount of time
    text
    copied!<p>I'm attempting with the following code to</p> <ol> <li>Display the results of a card game,</li> <li>Wait for 3 seconds while displaying a countdown and then,</li> <li><p>Reload the screen.</p> <pre><code>//Display results, at least that was the idea. for(var player = 0; player &lt; players.length; player++) { resultString = players[player][6] if (result == null) { resultString += ", its a tie."; } else { resultString += (player == 0 ? ", you" : ", cassino") + (player == result ? (player == 0 ? " win" : " wins") : (player == 0 ? " lose" : " loses")); document.getElementById(player == 0 ? "player" : "casino"). childNodes[0].nodeValue = resultString; } showHand(players[player]); } //Lag for 3 seconds while displaying a countdown. At least it lags alright. var time = new Date().getTime(); while (((time / 1000) + 3) - (new Date().getTime() / 1000 ) &gt; 0) { document.getElementById("call").childNodes[0].nodeValue = "Next round in " + Math.ceil(((time / 1000) + 3) - (new Date().getTime() / 1000 )) .toFixed(0); } //Reload screen. Working fine. dealHands(); } </code></pre></li> </ol> <p>The problem is that by running this code the screen instead <em>freezes</em> for 3 seconds before loading the reloading the screen, even though console.log points out no problems with the values to be displayed in the "//Display results" section of the program. In fact, if I comment the portion <em>after</em> the comment "//Lag for 3 seconds..." the results are displayed as intended. Is there some property of .time() that I'm unaware of that is overriding the code?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload