I am creating a webpage, and I want to add a functionality to it: I need to concatenate 2 strings using javascript. The first string is an input from a blank box (in which I can copy a link), and the second string is a constant string.

On the click of a button on the webpage, the concatenated string (which will be a web-address) should open in a new tab or window. I am trying with the following code:

<!DOCTYPE html>
<html>
<body>

<p>Click the button to join three strings into one new string.</p>

<button onclick="myFunction()">Go</button>

<p id="demo"></p>

<script>
function myFunction() {
var str1 = "www. ";
var str2 = "google";
var str3 = ".com";
var res = str1.concat(str2,str3);
document.getElementById("demo").innerHTML = res;
}
</script>

</body>

</html>
But instead of writing the result in the webpage itself, the Go button should open the link in a new tab. Also, instead of defining the string "www." in the code itself, I want to be able to enter it interactively by writing it in a blank box, but I am not getting how to code this.