Last active
October 21, 2015 14:10
-
-
Save kevincolten/cc5a8224757b2becd673 to your computer and use it in GitHub Desktop.
Car Objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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