Advertisement
Guest User

Untitled

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