I want to do a timer as an object.
The problem is that Im getting NAN instead of the increasing value of counter when I run the my Interval Method.
I understand that Im probably setting the this wrong, but I dont understand what exactly Im doing wrong with the this here.
What am I doing wrong?
timer = {
count: 0,
addASecond: function() {
this.count++;
console.log(this.count);
},
myInterval() {setInterval(this.addASecond,1000);}
}
timer.myInterval();
</script>
Thanks in advance
Fabian