Skip to content

Instantly share code, notes, and snippets.

@mstarkman
Created August 9, 2011 01:50
Show Gist options
  • Save mstarkman/1133257 to your computer and use it in GitHub Desktop.
Save mstarkman/1133257 to your computer and use it in GitHub Desktop.
JavaScript Masters Class - Exercise 1
// 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' });
// 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