I have function addNumber and if I click on button with specific value, the value is concatenate to variable b. But if the value of "a" is other than number, the function doesn't work. What am I missing? I thought that the function works with parameter "a" as if it was a string. Otherwise the number were add up. So if b=0, a=x; the result of b=b+a will be x.
function addNumber(a) {
b=b+a;
document.getElementById("result").innerHTML= b;
}
I think that problem is here.
function addNumber(a) {
document.getElementById("result").innerHTML= String(a);
}
If the parameter "a" is number, it returns number, but if the parameter "a" is equals some string, returns nothing. Why?
b = parseInt(b) ? b + a : a