-
Notifications
You must be signed in to change notification settings - Fork 12
[TrungPH] Submit exercise 1 -> 10 #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
phantien133
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TrungPH/ex2.ts
Outdated
| console.log(` - ${person.name}, ${person.age}`); | ||
| } | ||
|
|
||
| persons.forEach(logPerson); No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config editor auto add empty line vào cuối file đi em
TrungPH/ex4.ts
Outdated
| export function logPerson(person: Person) { | ||
| let additionalInformation: string = ''; | ||
| if (isAdmin(person)) { | ||
| additionalInformation = (person as Admin).role; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ntn hợp lý, k sai
cơ mà làm các bài sau rồi, e có để cách ng ta dùng hàm để xác định type luôn cho 1 object k?
check rồi update thử xem
TrungPH/ex6.ts
Outdated
| ); | ||
| } | ||
|
|
||
| export function getObjKeys<T extends object>(obj: T): (keyof T)[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T extends object thì thôi T là đc e ạ
| return Object.keys(obj) as (keyof T)[]; | ||
| } | ||
|
|
||
| export function filterPersons(persons: Person[], personType: string, criteria: Partial<Person>): Person[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
có cách nào để xác định đc luôn khi gọi hàm thfi object trả về là User[] hay Admin[] luôn k em
vì ngay khi truyền personType là đã xác định đc r
TrungPH/ex9.ts
Outdated
| } | ||
| ); | ||
|
|
||
| type AdminsApiResponse = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thử dùng generic type ở ApiResponse để tránh lặp lại 2 type mới khá trùng nhau ntn đc k e
|
@htrung1303 update phát em |
@phantien133 Em done anh oi |

Mong anh bửa nhẹ tay 🙏