Created
December 12, 2016 18:13
-
-
Save Louiefigz/a6364ea650465c1cc1ba3719dcc055be to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Sandwich(bread, ingredients, name) { | |
this.bread = bread; | |
this.ingredients = ingredients; | |
this.name = name; | |
} | |
function serve(customer) { | |
// From the variable gc, we have access to this.name | |
console.log("Hey " + customer + ", here's your " + this.name + ", enjoy!"); | |
} | |
var gc = new Sandwich("white", ["cheese"], "Grilled Cheese"); | |
var pbj = new Sandwich("wheat", ["peanut butter", "raspberry jam"], | |
"Peanut Butter & Jelly"); | |
// the second argument here is the 'customer' variable that is used in serve(). | |
// the first argumement here is the object that we are creating. | |
serve.call(gc, "Terry"); | |
serve.call(pbj, "Jesse"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment