Advertisement
Guest User

Untitled

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