Question 1
Back to Exercise
JavaScript refuses to run the code below. Which statement correctly describes the problem?
function add(a, b) {
return a + b;
console.log(add(2, 3));
- A a and b must be declared with let
- B SyntaxError: the function body is never closed – a } is missing after return a + b; Correct
- C console.log cannot be called after a function
- D add must be declared before it is called
Correct Answer: Option B
The parser reaches the end of the file still inside the function body: "SyntaxError: Unexpected end of input". Add the closing brace after the return statement.
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!