I'm trying to do something in Javascript where I call a return function inside of another function, all within a class, it goes something like this:
class MyClass {
constructor (x,y) {
this.x = x;
this.y = y;
}
newValues () {
this.x = findNextXValue(this.x);
}
findNextXValue (x) {
let changeVal = x + 5;
return changeVal;
}
}
When I try this code in p5js I get an error saying that findNextXValue is not defined. Why can't I do something like this? Any clarification would be appreciated, thanks.