Question 15
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
function f(x) {
{
let x = 2;
x *= 10;
}
return x;
}
console.log(f(1));
- A 20
- B 2
- C 1 Correct
- D SyntaxError
Correct Answer: Option C
The inner let x lives in its own block and hides the parameter only there. (A let x directly in the function body, next to the parameter, would be a SyntaxError.)
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!