-5

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!

1 Answers1

3
value: 1000, inc: 123, pace: 1000, auto: true

the pace is set to 1000 milliseconds mate!

Just change that number and you will have any speed you want!

dgp
  • 41
  • 3
  • But i need a Flip counter with several Speeds in one Script. In the beginning and end it shall count slow, in the middle part really fast... – user3595613 Feb 02 '16 at 19:52
  • why don't you just start it up three times, each time remember the previous value `value: previousValue` – dgp Feb 03 '16 at 17:08