Question 1
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log("10" - 4, "10" * "2", "10" / "4", "abc" * 2);
- A 106 1010 2.5 NaN
- B 6 20 2 abcabc
- C NaN NaN NaN NaN
- D 6 20 2.5 NaN Correct
Correct Answer: Option D
-, * and / convert strings to numbers. "abc" converts to NaN, and any arithmetic with NaN is NaN.
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!