Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created July 18, 2019 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/1ed29635c49f247cb8764ff4d5805581 to your computer and use it in GitHub Desktop.
Save ssaurel/1ed29635c49f247cb8764ff4d5805581 to your computer and use it in GitHub Desktop.
End Game method for the Click Speed Test Game in HTML5 on the SSaurel's Channel
function endGame() {
// we write final stats
var clicsBySeconds = (score / duration).toFixed(2);
timerTxt.textContent = duration.toFixed(3);
clicksTxt.textContent = clicsBySeconds;
// we show start button to play an other game
show(startBtn);
// we display result to the user in delayed mode
// to update DOM elements just before the alert
setTimeout(function() {
alert('You made ' + score + ' clicks in ' + duration +
' seconds. It is ' + clicsBySeconds + ' clicks by seconds. Try again!');
}, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment