Complete the code to declare an interface named Person.
interface [1] {
name: string;
age: number;
}The interface name should be Person to match the declaration.
Complete the code to create a variable of type Person.
const user: [1] = { name: 'Alice', age: 30 };
The variable user must be of type Person to match the interface.
Fix the error by completing the code to implement the interface correctly.
class Employee implements [1] { name: string; age: number; constructor(name: string, age: number) { this.name = name; this.age = age; } }
The class Employee must implement the Person interface to ensure it has the required properties.
Fill both blanks to create an interface and use it to type a function parameter.
interface [1] { title: string; completed: boolean; } function printTask(task: [2]) { console.log(`${task.title} is ${task.completed ? 'done' : 'not done'}`); }
The interface and the function parameter type must both be Task to match.
Fill all three blanks to create an interface, a variable, and a function using that interface.
interface [1] { id: number; name: string; } const product: [2] = { id: 1, name: 'Book' }; function showProduct(p: [3]) { console.log(`Product: ${p.name} (ID: ${p.id})`); }
All three blanks must be Product to keep the types consistent.
