A

Admin • 833.24K Points
Coach

Q. What does the following expression evaluate to?

Code:
console.log(1 + '2' + 3);
  • (A) 6
  • (B) 123
  • (C) 33
  • (D) 15
  • Correct Answer - Option(B)
  • Views: 26
  • Filed under category JavaScript
  • Hashtags:

Explanation by: Admin

JavaScript converts numbers to strings when one operand is a string. So 1 + '2' = '12', then '12' + 3 = '123'.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.