Created
October 6, 2015 17:34
-
-
Save ArielLeslie/55bd17cd8a4453e02733 to your computer and use it in GitHub Desktop.
Make Properties Private
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Let's create an object with a two functions. One attached as a property and one not. | |
var Car = function() { | |
this.gear = 1; | |
function addStyle(styleMe){ | |
return 'The Current Gear Is: ' + styleMe; | |
} | |
this.getGear = function() { | |
return addStyle(this.gear); | |
}; | |
}; | |
var Bike = function() { | |
// Only change code below this line. | |
speed = 100; | |
function addUnit(value) { | |
return value + "KM/H"; | |
} | |
this.getSpeed = function () { | |
return addUnit(speed); | |
}; | |
}; | |
// Only change code above this line. | |
var myCar = new Car(); | |
var myBike = new Bike(); | |
if(myBike.hasOwnProperty('getSpeed')){(function() {return JSON.stringify(myBike.getSpeed());})();} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment