[TS] TypeScript Exercises 1 해석 및 풀이
Introduce
We are starting a small community of users. For performance
reasons we have decided to store all users right in the code.
This way we can provide our developers with more
user-interaction opportunities. With user-related data, at least.
All the GDPR-related issues will be solved some other day.
This would be the basis for our future experiments during
these exercises.
우리는 이제 유저들을 위한 작은 커뮤니티 서비스를 시작할 에정입니다. 성능적인 이유로 우리는 모든 유저들을 코드 내에 저장하기로 결정했습니다. 이 방법으로 우리는 개발자들에게 더 유저와 상호작용할 수 있는 기회를 줄 수 있습니다. 최소한 유저와 관련된 데이터를 사용합니다. 모든 GDPR과 관련된 이슈들을 언젠가 해결될 것입니다. 이 연습기간동안 우리의 미래 실험의 기반이 될 것입니다.
Exercise
Given the data, define the interface "User" and use it accordingly.
주어진 데이터에서 User 인터페이스를 정의하고 사용해보세요
Code
export type User = {name: string, age: number, occupation: string};
export const users: User[] = [
{
name: 'Max Mustermann',
age: 25,
occupation: 'Chimney sweep'
},
{
name: 'Kate Müller',
age: 23,
occupation: 'Astronaut'
}
];
export function logPerson(user: User) {
console.log(` - ${user.name}, ${user.age}`);
}
console.log('Users:');
users.forEach(logPerson);
https://typescript-exercises.github.io/#exercise=1&file=%2Findex.ts
TypeScript Exercises
A set of interactive TypeScript exercises
typescript-exercises.github.io