I'm having a small issue adding variables together, I have a input number field set up to set the variable. Then all I'm then trying to do is post 3 numbers the first is the original, the second is the first plus the original, then the third is the second plus the original. But for some reason (clearly I'm missing something) as my variables are outputting as strings rather than integers?
function submit() {
var input = document.getElementById("input").value;
var p1 = parseInt(input);
var p2 = parseInt(p1) + input;
var p3 = parseInt(p2) + input;
document.getElementById("p1").innerHTML = p1;
document.getElementById("p2").innerHTML = p2;
document.getElementById("p3").innerHTML = p3;
}
<label for="input">Value</label><br>
<input type="number" id="input"><br>
<button id="btnSubmit" onclick="submit()">Submit</button>
<p id="p1">0</p>
<p id="p2">0</p>
<p id="p3">0</p>
+doesn't decide the mode of operation depending only on the first operand but on both: "If Type(lprim) is String or Type(rprim) is String, then". If either is a string, you are getting a string.