Skip to content
Advertisement

If the input I put blank, then it will count 0

I am trying to put some amount, then it will show the calculation if all input will given any number, but I want, when I do not put anything in any one of that input, then the input will count “0” automatically..

JavaScript

Advertisement

Answer

JavaScript

You can use the OR operator to replace NaN with 0 if parseFloat returns NaN.

You could shorten the upper code to:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement