title: Waiting for a method inside an object constructor to complete before continuing
body: <p>I am building a timer that counts from 25 mins to 0 and then from 5mins to 0 a certain number of times. Right now, I have a CountDownTimer object with a param of 25*60 that counts from 25 to 0. I want to start a new timer that would count from 5 to 0 once the other timer reaches 0. How do I implement this type of asynchronous code and then execute that asynchronous code X number of times?</p>
  
  <pre><code>$(document).ready(function(){
    var sessionBreakTimer = new CountDownTimer(25*60);
    sessionTimer.start();
    if (!sessionTimer.isRunning) {
      sessionBreakTimer.start();
    }
  );
  
  function CountDownTimer(secs) {
    var duration = secs;
    var running = false;
  
    this.start = function() {
      running = true;
      var startT = new Date().getTime();
      var intervalId = window.setInterval(function() {
        var msDelta = new Date().getTime() - startT; // milliseconds elapsed since start
        var secsLeft = duration - Math.floor(msDelta / 1000);
        if (secsLeft === 0) {
          window.clearInterval(intervalId);
          console.log("cleared");
          running = false;
        }
      }, 1000); //update about every second
    };
  
    this.isRunning = function() {
      return running;
    }
  
  }
  </code></pre>