So I want to add content like a string or another variable to a variable that already exists. I know this isn't right, but this is what I have.
var variable = "Variable";
function dispVar1() {
let p = document.createElement("p");
p.innerHTML = variable;
}
function dispVar2() {
let p = document.createElement("p");
let alteredVar = variable + " that has been altered";
/* Also, could I do "" + variable to make string go before the variable? */
p.innerHTML = alteredVar;
}
<input type="button" value="Original" onclick="dispVar1();">
<input type="button" value="Altered" onclick="dispVar2();">
+=to concatenate more onto the value."something" + variable. Why would the order make a difference?[<>]tool in the toolbar to open the snippet editor.innerHTMLand you should usep.textContentif you just add some text to it. Its more performant.