Advertisement
Tyrsdei

Untitled

Jul 3rd, 2018
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var currentYear = 2018
  2. var jason = {
  3.    
  4.     name: "Jason",
  5.     birthYear: 1987,
  6.     eyeColor: "blue",
  7.     height: 69,
  8.     age: calculateAge()
  9.    
  10. };
  11.  
  12. var ammy = {
  13.    
  14.     name: "Americity",
  15.     birthYear: 2009,
  16.     eyeColor: "blue",
  17.     height: 60,
  18.     age: calculateAge()
  19.    
  20. }
  21.  
  22. function calculateAge() {
  23.     this.age = currentYear - this.birthYear
  24. }
  25.  
  26. console.log(jason.age);
  27. console.log(ammy.age)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement