i've been looking for an answer but everything i find seems to be saying that i'm not doing anything wrong. I'm trying to call a prototype function inside another one, but i keep getting the error that it is not a function.
For some reason it only happens within one specific method (tick), the rest has no problem with the same methods.
Here is my code:
Timer.prototype.getTimeRemaining = function(){
return this.startTime - this.currentTimeTimed;
}
Timer.prototype.updateElement = function(){
document.getElementById("clock").innerHTML = this.getTimeRemaining();
return true;
}
Timer.prototype.tick = function(){
if (this.running){
this.currentTimeTimed += timePassedInMilliseconds;
}
this.getTimeRemaining();
this.updateElement();
}
So the error i get is in tick(): Uncaught TypeError: this.getTimeRemaining() is not a function.
While testing some more, i think i found out why: i think it is because the tick function is called from an interval. I'm not sure, but that's the only thing i can think of that's different from the other functions. But i don't know how i should change my code then, if it is caused by the interval.
Thanks in advance.