Question 6
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
function total() {
return
10 + 20;
}
console.log(total());
- A 30
- B 1020
- C undefined Correct
- D SyntaxError
Correct Answer: Option C
ASI inserts a semicolon right after return because a line break follows it. The function returns undefined and 10 + 20 is unreachable code – valid, but never run.
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!