I have the following code:
subir() {
this.y -= 5;
if(this.y <= 2) {
clearInterval(this.salto);
this.salto = setInterval("this.bajar()", this.vel);
}
}
bajar() {
this.y += 5;
if(this.y >= 15){
this.saltar = true;
clearInterval(this.salto);
}
}
These functions are inside a class
named Dinosaurio. When I call subir()
it works fine, and as you saw in the code, it should automatically call the bajar()
function after a few seconds. But bajar()
doesn't work, and instead I got in the console this.bajar() is not a function
What is causing this bug?