Stuck- Make Object Properties Private

Stuck- Make Object Properties Private
0

#1

Hello, Can someone kindly help me out here.

For some reason the code is running but i haven’t fully understood about the public properties vs private properties.

This code passed the test but i would appreciate if someone explains to me what is happening.
'
var Bike = function()
{

// Only change code below this line.
var gear = 5;

this.getGear = function()
{
return gear;
};
this.setGear = function(num)
{
gear = num;
};

};

var myCar = new Car();

var myBike = new Bike();

Thanks


#2

You can only access or modify gear through the methods. You cannot have myCar.gear = 5; for instance.