You can’t access values inside other functions, they only exist inside the function. If I write it out slightly differently (still same logic), is it any clearer why what you’ve written can’t work? (I don’t think you’ve meant to write what you have btw)
var bonus;
var like;
function changePoints(bonusChange, likeChange) {
bonus = bonusChange;
like = likeChange;
function sumPoints () {
// These two things don't exist, so this can't work
return bonusChange + likeChange;
}
These are two different functions. You can’t access variables that are declared only within one function in a different function. bonusChange + likeChange is trying to sum two things that a. don’t exist, and b. aren’t the things you want to sum.
The variables declared outside the functions (this.bonus and this.like), that’s fine, you can access those anywhere inside that Points function