Can't call a member function inside a member function of same object

Can't call a member function inside a member function of same object
0

#1
function Stopwatch(){
    let running;
    let counter;
    let duration = 0;

    this.add = function(){
        duration++;
        this.start;
    };

    this.start = function(){
        if(running){
            throw Error("Stopwatch is already running")
        }
        running = true;
        counter = setTimeout(this.add,1);
    
            
    };

    this.stop = function(){
        if(!running){
            throw Error("Stopwatch is not running");
        }else{
            clearTimeout(counter);
            running = false;
        }
    };

    this.reset = function(){
        duration = 0;
        running = false;
    };

    Object.defineProperty(this, 'duration', {
        get: function() { return duration; }
      });

};

let sw = new Stopwatch();

The above code is about a stopwatch. My problem is when the object is created and write in the console
sw.start()
the function runs properly and it executes add() after 1000 miliseconds interval then from the add function when it calls this.start again it doesn’t work I don’t get any error but the duration doesn’t increment from 1 to 2.

I tried using this.start() then it gives me an error that this.start is not a function

this.add = function(){
...
this.start();
};

#2

Not exactly sure how you are getting the error you describe with the code above.

Also, I am not exactly sure what you are expecting your code to do or what you ultimate goal is for this code.

Is this code part of a tutorial, because this is the second time this week I have seen a question related to a stopWatch function. The code was very similar to yours.