A

Admin • 833K Points
Coach

Q. What will be the output of the following JavaScript code snippet?

Code:
<p id="demo"></p>
var txt1 = "mcqbuddy_";
var txt2 = "Javascriptmcq";
document.getElementById("demo").innerHTML = txt1 + txt2;
  • (A) error
  • (B) mcqbuddy_ Javascriptmcq
  • (C) undefined
  • (D) mcqbuddy_Javascriptmcq
  • Correct Answer - Option(D)
  • Views: 22
  • Filed under category JavaScript
  • Hashtags:

Explanation by: Admin

The + operator in javascript acts as a concatenation operator when used with string. The new string does not have any space between the two added strings.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.