3.
What is the output of the following code?
function outerFunction() {
var x = 10;
function innerFunction() {
var y = 5;
console.log(x + y);
}
innerFunction();
}
outerFunction();
undefined
15
5
10
Correct: B
The code defines a nested function innerFunction inside outerFunction. When outerFunction is called, innerFunction is also invoked, and x (defined in outerFunction) has a value of 10, while y (defined in innerFunction) has a value of 5. Therefore, the sum of x and y is 15, which is printed to the console.