Home / Programming MCQs / JavaScript MCQs / Question

C

Chandani • 9.65K Points
Tutor III

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
Explanation by: Chandani
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.