Skip to content

Instantly share code, notes, and snippets.

@mhansen
Created August 25, 2009 05:04
Show Gist options
  • Save mhansen/174483 to your computer and use it in GitHub Desktop.
Save mhansen/174483 to your computer and use it in GitHub Desktop.
function makeCar(initialOdometer) {
var privateOdometer = initialOdometer;
return {
"getOdometer" : function() {
return privateOdometer;
}
"drive" : function(distance) {
if (distance > 0) privateOdometer += distance;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment