Answers for "adding a timer in a quiz game"

0

adding a timer in a quiz game

var sec = 15;
var time = setInterval(myTimer, 1000);

function myTimer() {
    document.getElementById('timer').innerHTML = sec + "sec left";
    sec--;
    if (sec == -1) {
        clearInterval(time);
        alert("Time out!! :(");
    }
}
Posted by: Guest on January-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language