Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. class Person {
  2.  
  3. constructor (name, age) {
  4. this.name = name;
  5. this.age = age;
  6. }
  7.  
  8. tellMyName () {
  9. return ` I am ${this.name}`;
  10. }
  11.  
  12. tellMyAge () {
  13. return ` I am ${this.age} years old`;
  14. }
  15. }
  16.  
  17.  
  18. const john = new Person("john", 40);
  19. const mary = new Person("mary", 35);
  20.  
  21.  
  22. console.log(john.tellMyName());
  23. console.log(john.tellMyAge());
  24.  
  25. console.log(mary.tellMyName());
  26. console.log(mary.tellMyAge());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement