We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3273c79 commit 2159707Copy full SHA for 2159707
src/index.ts
@@ -1,21 +1,22 @@
1
-interface Human {
2
- name: string;
3
- age: number;
4
- gender: string;
+class Human {
+ public name: string;
+ private age: number;
+ public gender: string;
5
+ constructor(name: string, age: number, gender: string) {
6
+ this.name = name;
7
+ this.age = age;
8
+ this.gender = gender;
9
+ }
10
}
11
-const person = {
- name: "nicolas",
- age: 22,
- gender: "male"
-};
12
+const lynn = new Human("Lynn", 18, "female");
13
14
const sayHi = (person: Human): string => {
15
return `Hello ${person.name}, you are ${person.age}, you are a ${
16
person.gender
17
}!`;
18
};
19
-console.log(sayHi(person));
20
+console.log(sayHi(lynn));
21
22
export {};
0 commit comments