Complete the code to declare a variable with a type annotation.
let username: [1] = 'Alice';
In TypeScript, you declare a variable's type after the colon. Here, username is a string.
Complete the function parameter with the correct type annotation.
function greet(name: [1]): string { return `Hello, ${name}!`; }
The parameter name should be a string because it is used inside a text message.
Fix the error by adding the correct type annotation to the array.
const scores: [1] = [10, 20, 30];
The array scores contains numbers, so its type is number[].
Fill both blanks to define an interface and use it to type an object.
interface [1] { id: number; name: string; } const user: [2] = { id: 1, name: 'Bob' };
The interface is named User and the object user uses this interface as its type.
Fill all three blanks to create a typed function with a return type.
function add(a: [1], b: [2]): [3] { return a + b; }
The function add takes two numbers and returns a number, so all types are number.
