I have this following Code:
var count=0;
var counter=setInterval(timer, 50); //1000 will run it every 1 second
function timer()
{
count=count+1;
if (count >= 24)
{
clearInterval(counter);
//counter ended, do something here
document.getElementById("countdown").innerHTML=24 ;
return;
}
//Do code for showing the number of seconds here
document.getElementById("countdown").innerHTML=count ; // watch for spelling
}
#countdown{
font-size: 5em ;
}
<div id="countdown">0</div>
I'd like to set up the counter, so it runs in different speeds.
From count 0 to 10 - speed = 50
From count 11 to 20 - speed = 500
From count 21 to 50 - speed = 5000
I'd tried to add the line
if (count == 11)
{var counter=setInterval(timer, 500); }
but this didn't work.
How can I realize to setup three different speeds in one function?
Thank you for your help!