Question 2
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log("2" + 3 + 4);
console.log(2 + 3 + "4");
- A 9 9
- B 234 234
- C 234 54 Correct
- D 27 54
Correct Answer: Option C
+ is evaluated left to right. "2" + 3 is "23", then "234". In the second line 2 + 3 is 5 first, then 5 + "4" is "54".
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!