Hello, if someone could help me with this task. Dont know what I’m missing…
var Bike = function() {
var gear = 0;
this.setGear = function (i) {
gear += i;
};
this.getGear = function() {
return gear;
};
};
Hello, if someone could help me with this task. Dont know what I’m missing…
var Bike = function() {
var gear = 0;
this.setGear = function (i) {
gear += i;
};
this.getGear = function() {
return gear;
};
};
Hi,
In your setGear method you’re adding i to the gear total each time… I think this would mean that your gear numbers will keep incrementing. What you want is for ‘gear = i’.
Cheers,
Tim
gear += i;
this is same as gear = gear + i
is that the desired effect ?
‘gear = i’ solved the problem…