Complete the code to declare a variable that can only be null.
let value: [1] = null;The type null allows the variable to hold only the null value.
Complete the code to declare a variable that can be either a string or undefined.
let name: [1];The union type string | undefined allows the variable to hold a string or be undefined.
Fix the error in the function parameter type to accept null or string.
function greet(message: [1]) {
console.log(message);
}The parameter type string | null allows the function to accept either a string or null value.
Fill both blanks to create a variable that can be a number, null, or undefined.
let count: [1] [2] null | undefined;
The union type number | null | undefined allows the variable to hold a number, null, or undefined.
Fill all three blanks to define a function that returns a string or undefined and accepts a nullable string parameter.
function process(input: [1]): [2] [3] undefined { if (input === null) return undefined; return input.toUpperCase(); }
The parameter type string | null allows null or string input. The return type string | undefined allows returning a string or undefined.