title: Node.js and socket.io timer reset
body: <p>hi Guys how can i reset my timer to 10 sec when my timer turns to 0 below is my code. What happen in my current code it doesnt restart to zero when i declare in the connection.</p>
  
  <p><code>app.js :</code>    </p>
  
  <pre><code>countdown = 10;
  var onInterval = function() {
      countdown--;
      if(countdown == 0){
          var endTime = currTimer();
  
          clearInterval(myInterval);
    io.sockets.emit('timer', { timer: countdown });
  
  };
  var myInterval = setInterval(onInterval, 1000);
  
  io.sockets.on('connection', function (socket){
      socket.on('restart timer', function (data) {
           setTimeout(function(){
              countdown = 10;
              myInterval = setInterval(onInterval, 1000);
          }
      }
  }
  </code></pre>