Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. class Person{
  2. constructor(name, age){
  3. this.name = name;
  4. this.age = age;
  5. }
  6. getName(){
  7. console.log("i am "+ this.name);
  8. }
  9. getAge(){
  10. console.log("I am "+ this.age+" years old.");
  11. }
  12. }
  13.  
  14. const person1 = new Person("Jhon", 25);
  15. const person2 = new Person( "Mary", 45);
  16.  
  17. person1.getName() + person1.getAge()
  18. person2.getName() + person2.getAge()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement