I am learning javascript and trying to complete a simple excercise: add 2 numbers that are entered in 2 separate entry field and show the sum on a page. The script below is executed when you press a button. The problem I'm somehow unable to solve is that the result of the addition is always zero. What I am doing wrong here?
var inputA = document.getElementById("numberA");
var convertA = +inputA;
var inputB = document.getElementById("numberB");
var convertB = +inputB;
function myFunction() {
document.getElementById("result").innerHTML = convertA + convertB;
}
debuggerin your code to automatically stop the script when the console is open. You can also useconsole.log(yourVariable)to display the value of your variable