Im trying to program a sort of game where you have 4 seconds to do answer a question (verbally) and once it’s up it moves on to the next question. I need it to play audio (not what im asking here), then countdown from 4 seconds to 0 and then display the correct answer and move on.
How can I create a countdown that goes from 4 to 0 seconds and then after moves on to the next thing?
I’ve tried the following and have failed.
var counter = 4;
$('#seconds').html(counter);
function decreaseSeconds(){
counter--;
$('#seconds').fadeOut('fast');
$('#seconds').html(counter).delay(800);
$('#seconds').fadeIn('fast');
}
while ( counter > 0){
decreaseSeconds()
}
See DEMO