Advertisement
NonplayerCharacter

JS | Jonas | Object 101

Jul 6th, 2022
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const jonas = {
  2.     firstName : "Jonas",
  3.     lastName : "Schmonas",
  4.     birthYear : 1991,
  5.     job : "teacher",
  6.     friends : ["Joe","Jim","Lou"],
  7.     hasDriversLicense: true,
  8.     calcAge : function(){
  9.         return 2037 - this.birthYear;
  10.     },
  11.     getSummary : function(){
  12.         return `${this.firstName} is a ${this.calcAge()}-year old ${this.job}, who has ${this.hasDriversLicense ? "a" : "no"} drivers license.`
  13.     }
  14. };
  15. console.log(jonas.getSummary());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement