Created
November 25, 2022 19:26
-
-
Save IacovColisnicenco/f1344d01262945a38e43f42e930120a6 to your computer and use it in GitHub Desktop.
Example js object with method
This file contains 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
// Online Javascript Editor for free | |
// Write, Edit and Run your Javascript code using JS Online Compiler | |
const obj = { | |
name: 'Iacov', | |
age: function(yearOfBirth) { | |
const date = new Date().getFullYear(); | |
const res = date - yearOfBirth; | |
return console.log(`I'm ${res} years old`); | |
} | |
}; | |
//Put your age as a paramiter | |
const res = obj['age'](1987); | |
//console.log(res); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment