Skip to content

Commit 3273c79

Browse files
#5 Interfaces on Typescript
1 parent 384bed6 commit 3273c79

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
const sayHi = (name: string, age: number, gender: string): string => {
2-
return `Hello ${name}, you are ${age}, you are a ${gender}!`;
1+
interface Human {
2+
name: string;
3+
age: number;
4+
gender: string;
5+
}
6+
7+
const person = {
8+
name: "nicolas",
9+
age: 22,
10+
gender: "male"
11+
};
12+
13+
const sayHi = (person: Human): string => {
14+
return `Hello ${person.name}, you are ${person.age}, you are a ${
15+
person.gender
16+
}!`;
317
};
418

5-
console.log(sayHi("Nicolas", 24, "male"));
19+
console.log(sayHi(person));
620

721
export {};

0 commit comments

Comments
 (0)