Advertisement
Guest User

Untitled

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