Return to Snippet

Revision: 58952
at August 11, 2012 00:33 by LucasRinaldi


Initial Code
var count = 0;
var timer;
var timerOn = false;

function timedCount() {
  count++;
  timer = setTimeout(function(){
    timedCount()
  }, 1000);
}

function doTimer() {
  if (!timerOn) {
    timerOn = true;
    timedCount();
  }
}

function stopCount() {
  clearTimeout(timer);
  timerOn = false;
}

Initial URL

                                

Initial Description
Just a counter

Initial Title
Count with setTimeout

Initial Tags

                                

Initial Language
JavaScript