Complete the code to declare a variable inside a function.
function greet() {
let message = [1];
console.log(message);
}
greet();The variable message needs to be assigned a string value. Strings must be in quotes.
Complete the code to create a new execution context by calling a function.
function showNumber() {
console.log(5);
}
[1]();Calling the function showNumber() creates a new execution context.
Fix the error in the code to correctly access a variable inside the execution context.
function count() {
let number = 10;
console.log([1]);
}
count();The variable number is declared inside the function and must be accessed by its exact name.
Fill both blanks to create an execution context with a local variable and a condition.
function checkAge(age) {
if (age [1] 18) {
return [2];
}
return "Too young";
}
console.log(checkAge(20));The condition checks if age is greater than or equal to 18, then returns "Allowed".
Fill all three blanks to create a function that returns a greeting with a name.
function greetUser([1]) { let greeting = `Hello, [2]!`; return [3]; } console.log(greetUser("Alice"));
The function takes name as a parameter, uses it inside a template string with ${name}, and returns the greeting variable.