Created
August 9, 2011 01:50
-
-
Save mstarkman/1133257 to your computer and use it in GitHub Desktop.
JavaScript Masters Class - Exercise 1
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
// Functional Version | |
window.logCar = function(carOptions){ | |
if (carOptions.hasOwnProperty('color') && carOptions.hasOwnProperty('make')) | |
console.log("I'm a " + carOptions.color + " " + carOptions.make); | |
else | |
console.log("I can't tell you about the car!"); | |
} | |
logCar({ color: 'blue', make: 'BMW' }); |
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
// OO Version | |
function Car(make, color) { | |
this.make = make; | |
this.color = color; | |
this.log = function() { | |
console.log("I'm a " + this.color + " " + this.make); | |
} | |
}; | |
(new Car('Ferrari', 'red')).log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment