Complete the code to declare a variable with type number.
let age: [1] = 30;
string type when assigning a number.boolean type for numeric values.The variable age is declared with type number, so it can only hold numeric values.
Complete the code to assign a string value to a variable declared as string.
let name: string = [1];The value assigned to name must be a string, so it needs to be in quotes like "Alice".
Fix the error by completing the code to assign a compatible type.
let isActive: boolean = [1];The variable isActive expects a boolean value. Only false is a valid boolean here.
Fill both blanks to create a compatible assignment between two interfaces.
interface Person { name: string; age: number; }
interface Employee extends Person { [1]: string; }
let emp: Employee = { name: "Bob", age: 25, [2]: "Manager" };The Employee interface adds a position property. The object emp must include this property with a string value.
Fill all three blanks to complete a function that checks assignment compatibility with union types.
function printId(id: [1]) { if (typeof id === [2]) { console.log("ID is a number: " + id); } else if (typeof id === [3]) { console.log("ID is a string: " + id); } }
The function accepts an id that can be a number or string. The typeof checks must match the string literals "number" and "string".