yejineee / typescript-study

Gladi와 Yejineee가 뿌시는 🆃🆂
1 stars 0 forks source link

Typescript Exercise 1번 문제 #1

Open yejineee opened 2 years ago

yejineee commented 2 years ago

GitHub: https://github.com/typescript-exercises/typescript-exercises

yejineee commented 2 years ago
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);
jongeunk0613 commented 2 years ago
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);