Skip to content

Instantly share code, notes, and snippets.

@jasonmw
Created November 11, 2011 05:44
Show Gist options
  • Save jasonmw/1357300 to your computer and use it in GitHub Desktop.
Save jasonmw/1357300 to your computer and use it in GitHub Desktop.
Homework 1 from Mastering JS Class
var logCar = function(){
var inp = arguments[0];
return function(){
console.log("I'm a " + inp.color + ' ' + inp.make);
};
};
var Car = function(make,color){
this.make = make;
this.color = color;
}
Car.prototype.log = function(){
console.log("I'm a " + this.color + ' ' + this.make);
};
var Car2 = function(make,color){
this.make = make;
this.color = color;
this.log = function(){console.log("I'm a " + this.color + ' ' + this.make);};
}
// tests
logCar({ color: 'blue', make: 'BMW' })();
(new Car('Ferrari', 'red')).log();
(new Car2('Ferrari', 'red')).log();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment