Tell us what’s happening:
Not sure why i get a green check for “myBike.getGear() should return 4 after calling myBike.setGear(4).” but the i dont for the 2 below it using my code.
Your code so far
var Car = function() {
// this is a private variable
var speed = 10;
// these are public methods
this.accelerate = function(change) {
speed += change;
};
this.decelerate = function() {
speed -= 5;
};
this.getSpeed = function() {
return speed;
};
};
var Bike = function() {
// Only change code below this line.
var gear = 1;
this.setGear = function(change){
gear *= change;
};
this.getGear = function(){
return gear;
};
};
var myCar = new Car();
var myBike = new Bike();
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/make-object-properties-private