Q:

Use Javascript or JQuery to create an href URL using variables passed in through URL parameters

Use Case:
I want to have dynamic button on a landing page that links to a different URL based on the parameters in the landing page URL.   
For example:
landing page link = www.testpage.com/?dc=secondtestpage.com
Desired Button Link = 'https://www.'  + dc + '? etxratrackingparameters'
   with the outcome =  "https://www.secondpagetest.com?extratrackingparameters"
I found this code to pull data from parameters:

// Parse the URL parameter
function getParameterByName(name, url) {
    if (! url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]"  + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (! results) return null;
    if (! results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}
// Give the parameter a variable name
var dynamicContent = getParameterByName('dc');

This allows me to pull the dc parameter into a variable.   Now I need to know how to use that variable to create URL by concatenating it to other variables or strings. 
Hopefully this easy for any Javascript experts (which I am not!).   Any help is appreciated. 
Thanks!  

A:

Building on what you already have.  Just use string concatenation to build the url, and use jQuery's .html() to create a link:

var dynamicContent = "secondpagetest.com";
var url = "https://www. "+dynamicContent+"?extratrackingparameters";
$('#container').html('<a href="'+url+'">link</a>');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container"></div>

