You are not assigning a new value to speed
go with -=
and +=
instead of – and +
this.getSpeed = function () {
return speed;
}
this.accelerate = function () {
return speed += acceleration;
}
this.decelerate = function () {
return speed -= acceleration;
}
solved How to make methods inside a constructor reference its argument? [closed]