Question 14
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const grade = (m) => (m >= 90 ? "A" : m >= 60 ? "B" : "C");
console.log([95, 72, 40].map(grade).join(""));
- A ABC Correct
- B AAB
- C CBA
- D ABB
Correct Answer: Option A
The whole ternary is one expression, so the arrow returns it implicitly; map passes each mark to grade.
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!