문제

I was wondering how I make a countdown timer. I have a puzzle app, and one of the puzzles are quick math. It shows a math question in a prompt, but I wanted to put a timer on it before it moves on to the next question. How would I do this?

도움이 되었습니까?

해결책

You can try somethink like this, and make o popup for asking user, simple example on fiddle

(function () {
   var timeToWaitInSeconds = 10;

    function countdown(){
    console.log(timeToWaitInSeconds);
    timeToWaitInSeconds -= 1;

        if (timeToWaitInSeconds>0){
            setTimeout(countdown,1000);
        }
    }

    setTimeout(countdown,1000);
}());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top