In Javascript, null, undefined, "" (empty string), false, 0, NaN are false values. The condition of checking a variable having any of these values โโleads to a false one.
In your case, you can simply check if the variable is false or not, and if you need to exclude 0 from this condition, you can add another test of the condition if the variable! == 0.
for example, in the code below they say that โaโ is a variable that you need to check against all false values โโexcept 0, and then you can check (a! == 0) && &! a (and not fake) and assign N / A, leave "a" as it is.
line 1: var a = 0; line 2: a = (a! == 0 &! a)? "N / A": a;
I hope the code above can help you.
source share