Skip to content

Instantly share code, notes, and snippets.

@kevincolten
Last active October 21, 2015 14:10
Show Gist options
  • Save kevincolten/cc5a8224757b2becd673 to your computer and use it in GitHub Desktop.
Save kevincolten/cc5a8224757b2becd673 to your computer and use it in GitHub Desktop.
Car Objects
function Car(color) {
this.color = color;
this.tires = 4;
this.drive = function() {
console.log("VVRRROOOMMM!!!")
}
}
function Driveway(maxCars) {
this.cars = [];
this.maxCars = maxCars;
this.parkHere = function(car) {
if (this.cars.length < maxCars) {
this.cars.push(car);
} else {
console.log("No Vacancy");
}
}
}
// to load into node, type "node" in the command line and ".load Cars.js" (make sure you are in the same directory)
// also, you can make an account at tonicdev.com and put it in a notebook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment