Skip to content

Instantly share code, notes, and snippets.

@kironroy
Created May 3, 2023 18:20
Show Gist options
  • Save kironroy/a95e3853ab796702cd07b374d24b624e to your computer and use it in GitHub Desktop.
Save kironroy/a95e3853ab796702cd07b374d24b624e to your computer and use it in GitHub Desktop.
JavaScript objects
console.log(vini.getSummary());
const grace = {
firstName: 'Grace',
lastName: 'Kelly',
birthYear: 1945,
job: 'Actor',
sisters: ['Pam', 'Bonnie', 'Michelle'],
hasDriversLicense : true,
calcAge: function () {
this.age = 2037 - this.birthYear;
return this.age;
},
getSummary: function() {
return `${this.firstName} ${this.lastName} is a ${this.calcAge()}-year old ${vini.job}, and she has ${this.hasDriversLicense ? 'a' : 'no'} driver's license.`
}
};
console.log(grace.getSummary());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment