25 lines
463 B
TypeScript
25 lines
463 B
TypeScript
interface Person {
|
|
name: string;
|
|
age: number;
|
|
email: string;
|
|
}
|
|
|
|
function greet(person: Person): string {
|
|
return `Hello, ${person.name}! You are ${person.age} years old.`;
|
|
}
|
|
|
|
const user: Person = {
|
|
name: "Alice",
|
|
age: 30,
|
|
email: "alice@example.com",
|
|
};
|
|
|
|
console.log(greet(user));
|
|
console.log(`Email: ${user.email}`);
|
|
|
|
function calculateSum(a: number, b: number): number {
|
|
return a + b;
|
|
}
|
|
|
|
console.log(`Sum of 5 and 10 is: ${calculateSum(5, 10)}`);
|