Created
October 31, 2014 04:03
-
-
Save TessMyers/5e404260d7882c92433f 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
var makeCat = function(){ | |
var cat = {}; | |
cat.stomach = []; | |
cat.meow = function(){ | |
console.log("MEOW"); | |
}; | |
cat.eat = function(food){ | |
cat.stomach.push(food); | |
}; | |
return cat; | |
}; | |
var kitty = makeCat(); | |
kitty.meow(); // "MEOW" | |
kitty.eat('mouse'); | |
console.log(kitty.stomach); // ["mouse"] | |
kitty.eat('owner'); | |
console.log(kitty.stomach); // ["mouse", "owner"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment