Complete the code to declare a variable with a number type annotation.
let age: [1] = 30;
The number type annotation tells TypeScript that age must hold a number value.
Complete the function parameter with the correct type annotation.
function greet(name: [1]) { console.log(`Hello, ${name}!`); }The parameter name should be a string because it represents text.
Fix the error by adding the correct return type annotation to the function.
function add(a: number, b: number): [1] { return a + b; }
The function returns the sum of two numbers, so the return type is number.
Fill both blanks to create a typed object with a name and age.
const person: { name: [1]; age: [2] } = { name: 'Alice', age: 25 };The name is text, so it uses string. The age is a number, so it uses number.
Fill all three blanks to type a function that returns a boolean indicating if a number is positive.
function isPositive(num: [1]): [2] { return num [3] 0; }
The parameter num is a number. The function returns a boolean. The comparison operator is >.