Skip to content

Instantly share code, notes, and snippets.

@muloka
Created March 3, 2011 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muloka/853572 to your computer and use it in GitHub Desktop.
Save muloka/853572 to your computer and use it in GitHub Desktop.
JSMC Exercise 3
// functional
var logCar = function (obj){
return function(){
"I'm a" + obj.color + " " + obj.make;
}
}
// Example call for functional version:
logCar({ color: 'blue', make: 'BMW' });
// oo
var Car = function (color,make){
this.color = color;
this.make = make;
}
Car.prototype.log = function() {
return "I'm a" + this.color + " " + this.make;
}
// Example call for OO version:
(new Car('Ferrari', 'red')).log();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment