In Javascript, I wanted to calculate total of two variables received from textbox, let us say txtBoxA and txtBoxB. The value gets calculated in an anonymous function and is stored in a variable total. Please take a look at the following code to see how it is calculated:
var total = function () {
var total = parseFloat(txtbox[1].value) + parseFloat(txtbox[2].value);
if (total == NaN) return 0;
else return total;
};
alert(total);
but unfortunately, the anonymous function itself is printed as it is as shown in the image below.
