Search This Blog

Thursday, 28 July 2016

How to Join two strings in javascript?

Html page:

<button onclick="myFunction()">Try it</button>
<p id="demo"></p>

Javascript page:

<script>
function myFunction()
{
    var str1 = "Hello ";
    var str2 = "world!";
    var res = str1.concat(str2);
    document.getElementById("demo").innerHTML = res;
}
</script>

Output:

Hello world!

No comments:

Post a Comment