Hi guys!
This is my first post on the freecodecamp Forum. I seek help regarding the topic “Make Object Properties Private”. Here is the code which is pre-written :
var Car = function() {
var speed = 10;
this.accelerate = function(change) {
speed += change;
};
this.decelerate = function() {
speed -= 5;
};
this.getSpeed = function() {
return speed;
};
};
var Bike = function() {
};
var myCar = new Car();
var myBike = new Bike();
Over Here, in the accelerate property, you have a parameter called change. How will you call that? How will you put value in the change parameter? because when you will call the variable car, you wont be able to put any value in it as parameter because the function called “function” doesn’t itself have any predefined “enter-able” parameter…