Last active
April 28, 2023 10:14
-
-
Save Snoupix/c82064cfe8f7e107ad63bff029683b02 to your computer and use it in GitHub Desktop.
Quest challenge Wild Code School
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User = { | |
name: string | |
age?: number | |
birthday?: string | |
}; | |
const prettyPrintWilder = (users: Array<User>): void => { | |
users.map((user) => { | |
console.log( | |
user.age != undefined | |
? `${user.name} is ${user.age} years old` | |
: `${user.name} is born the ${user.birthday}` | |
); | |
}); | |
}; | |
const wilders: Array<User> = []; | |
const user1: User = { name: "Pierre", age: 23 }; | |
const user2: User = { name: "Paul", birthday: "10/02/1990" }; | |
const user3: User = { name: "Jacques", age: 25 }; | |
wilders.push(user1); | |
wilders.push(user2); | |
wilders.push(user3); | |
prettyPrintWilder(wilders); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment