Single Choice Not Set

QWhat is the result of the following code?
console.log(5 + 5 + '5');

ID: #4860 JavaScript Operator MCQ 303 views
Question Info
#4860Q ID
Not SetDifficulty
JavaScript Operator MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A '105'
  • B '55'
  • C 55
  • D '10'
Correct Answer

Explanation

The result of the code is '105'.
In JavaScript, the + operator has two different meanings depending on the type of the operands.
If at least one of the operands is a string,
the + operator performs string concatenation.
In this case, the first 5 is converted to the string '5',
and the second 5 is also converted to the string '5', so the final result is '105'.

No Previous Next Question

Share This Question

Challenge a friend or share with your study group.