What is the output of the following? “`js console.log(1 + ‘2’ + 3); console.log(1 + 2 + ‘3’); “`

JavaScript Developer Hard

JavaScript Developer — Hard

What is the output of the following? “`js console.log(1 + ‘2’ + 3); console.log(1 + 2 + ‘3’); “`

Key points

  • JavaScript concatenates strings when using the `+` operator with a string
  • JavaScript converts numbers to strings when using the `+` operator with a string
  • The order of operands in the expression affects the output

Ready to go further?

Related questions