I'm trying hard to understand basic concepts of javascript. The code below seems to be working fine if I use only "gear += 1" in line 8 below, but I cannot understand why is this not working when I'm using "this.gear += 1". It gives result as NaN. Thank you.
(function bike(speed, tank, gear) {
var i = {};
i.speed = speed;
i.tank = tank;
i.gear = gear;
i.addgear = (function() {
// works fine with "return gear+= 1" Why not with "this"?
return this.gear += 1;
})();
console.log("mybike", i);
})(120, 12, 5);