JavaScript

What is the output of `console.log(2 + '2')`?

Easy
5
Added
The output is '22' because JavaScript converts numbers to strings in string concatenation.

Solution Code

JavaScript
console.log(2 + '2'); // '22'
Explanation
When using + with a number and string, JavaScript converts the number to a string and concatenates.

Guided Hints

What happens when you add a number and a string?
Look up type coercion in JavaScript.