I’m learning JavaScript and I wanted to accept user input and add a number to it ,but instead of outputting 12+12 = 24
it’s outputting 12+ 12 = 1212
.
document.getElementById("mybutton").onclick = function(){
var myAge = document.getElementById("mytext").value + 12;
document.getElementById("value").innerHTML = myAge;
}
I tried doing:
myName = Number(myName)
but it didn’t work