Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
95
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. tellMyName() {
  7. return `I am ${this.name}`
  8. }
  9.  
  10. tellMyAge() {
  11. return `I have ${this.age} years old`
  12. }
  13. }
  14.  
  15. const firstPerson=new Person("John","40");
  16. const secondPerson=new Person("Mary","35");
  17. console.log(firstPerson.tellMyName() ,"and" ,firstPerson.tellMyAge());
  18. console.log(secondPerson.tellMyName(), "and" ,secondPerson.tellMyAge());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement