Skip to content

Instantly share code, notes, and snippets.

@kotAPI
Created July 17, 2017 08:33
Show Gist options
  • Save kotAPI/00b79dcee307ad15c7e32a2fdaaa1816 to your computer and use it in GitHub Desktop.
Save kotAPI/00b79dcee307ad15c7e32a2fdaaa1816 to your computer and use it in GitHub Desktop.
var InventoryDetails = function(obj){
obj.GetInventoryDetails = function(){
console.log("You are "+this.name+ " and you have "+ this.pencils + " pencils and "+ this.pens+ " pens.");
}
}
var JackInventory = {
name:"Jack",
pencils:264,
pens:23
}
var DonInventory = {
name:"Don",
pencils:361,
pens:68
}
InventoryDetails(JackInventory);
InventoryDetails(DonInventory)
JackInventory.GetInventoryDetails();
DonInventory.GetInventoryDetails();
// => You are Jack and you have 264 pencils and 23 pens.
// => You are Don and you have 361 pencils and 68 pens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment