Created
July 18, 2019 10:43
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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