Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
txt1 = “ one”;
txt1 += “two”;
document.getElementById(“demo”).innerHTML = txt1;
</script>

What will be the output of the following JavaScript code?
<p id=”demo”></p>
<script>
txt1 = “ one”;
txt1 += “two”;
document.getElementById(“demo”).innerHTML = txt1;
</script>
a) onetwo
b) error
c) one two
d) undefined

Answer: a
Explanation: The += operator acts in the same way as the concatenation operator in the string. There is no space added when two string are added together with += operator.

Join The Discussion