Help with Constructor for Pomodoro Clock

Hi crew,

I am trying to create a Timer constructor rather than using global vars. I have issues getting the clear interval to reference to the timer defined in setinterval. This is the code:


  // Timer constructor
  function Timer(duration) {
    this.durationTime = duration;

  Timer.prototype.startTimer = function() {
    var timer = setInterval(function(){
      if(this.durationTime >= 0){

   Timer.prototype.stopTimer = function() {

  var myTimer = new Timer(1000); // 10s timer

}); // end of DRF

var timer scopes the variable to just that function. You could use this.timer.