Complete the code to set a default value for the parameter name.
function greet(name: string = [1]) { return `Hello, ${name}!`; }
The default value for name is set to the string "Guest". This means if no argument is passed, name will be "Guest".
Complete the function to set a default number parameter with type.
function multiply(x: number, y: number = [1]): number { return x * y; }
The default value for y is 2, a number matching the parameter type number.
Fix the error by completing the default parameter with the correct type.
function setFlag(flag: boolean = [1]): string { return flag ? "On" : "Off"; }
The default value for flag must be a boolean true, not a string or number.
Fill both blanks to create a function with a default string parameter and return type.
function welcome(message: [1] = [2]): string { return message; }
The parameter message is typed as string with a default value "Hello". The function returns a string.
Fill all three blanks to define a function with a default boolean parameter and a typed return.
function isActive(status: [1] = [2]): [3] { return status; }
The parameter status is typed as boolean with default true. The function returns a boolean.