Question 2
Back to Exercise
JavaScript refuses to run the code below. Which statement correctly describes the problem?
const ages = [12, 25, 17, 40];
const adults = ages.filter((a) => a >= 18;
console.log(adults);
- A SyntaxError: the filter( call is never closed – add ) before the semicolon Correct
- B It prints [ 25, 40 ]
- C It prints []
- D TypeError
Correct Answer: Option A
The semicolon appears while the argument list is still open. ages.filter((a) => a >= 18); fixes it.
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!