Skip to content

Instantly share code, notes, and snippets.

@teasmade
Created September 23, 2024 17:10
Show Gist options
  • Save teasmade/39d3cd35cdfb4deca43b9b521b7c1724 to your computer and use it in GitHub Desktop.
Save teasmade/39d3cd35cdfb4deca43b9b521b7c1724 to your computer and use it in GitHub Desktop.
WCS TS-POO Q1
class Person {
name: string;
age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
tellMyName() {
console.log(`I am ${this.name}`);
}
tellMyAge() {
console.log(`I am ${this.age} years old`);
}
}
const john = new Person('John', 40);
john.tellMyName();
john.tellMyAge();
const mary = new Person('Mary', 35);
mary.tellMyName();
mary.tellMyAge();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment