Hi I am trying to create a JS object that would serve me as a timer for my project but I have run into one problem.
const timer = {
timePassed : 0,
countStart : Date.now(),
display : document.querySelector(".timer-display-value"),
updateTimer : function() {
let delta = Date.now() - this.countStart;
this.timePassed = Math.floor(delta / 1000);
this.display.textContent = this.timePassed;
},
startTiming : setInterval(
this.updateTimer
,500
),
start : function() {
this.countStart = Date.now();
this.startTiming();
},
stop : function() {
clearInterval(timer.startTiming());
}
};
With that code when I am trying to call the startTiming method i get an error that it is not a function. I have already spent some time trying to fix it and i have no idea what the problem may be.