Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 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.  
  13. tellMyAge() {
  14. return `I am ${this.age} years old`;
  15. }
  16. }
  17.  
  18. const john = new person ("john", 40);
  19. const marie = new person ("marie", 35);
  20.  
  21. console.log(john.tellMyName());
  22. console.log(john.tellMyAge());
  23.  
  24. console.log(marie.tellMyName());
  25. console.log(marie.tellMyAge());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement