Skip to content

Instantly share code, notes, and snippets.

@lenafaure
Created May 7, 2017 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lenafaure/2d8ea96945d7e4d34b503ed2d3c7b668 to your computer and use it in GitHub Desktop.
Save lenafaure/2d8ea96945d7e4d34b503ed2d3c7b668 to your computer and use it in GitHub Desktop.
var customer = {
firstName: "John",
lastName: "Doe",
greetCustomer: function(){
console.log("Hello again " + this.firstName + " " + this.lastName + "!");
},
calculateAge: function(currentYear, birthDate){
console.log(this.firstName + " is " + (currentYear - birthDate) + " years old.");
}
}
customer.calculateAge(2016, 1956); // Prints "John is 60 years old."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment