Advertisement
Guest User

Untitled

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