Condition in Javascript doesn't work -


i'm mad because of conditions in javascript. why 1 doesn't work?

if (isnan(first) || isnan(second) && (act !== '-' || act !== '+')) 

it should check first number, second number , act minus or plus. it's right numbers doesn't check act correct. what's wrong?

e.g. first 1, act a, second 2. won't work.

p.s.

i've knowledge in c++ , java. i've never had problems it. since time i've started learn javascript, many mistakes this.

is there different system of such expressions?

it should check first number, second number , act minus or plus. it's right numbers doesn't check act correct.

thus requirement stated above correct statement be

if ( !isnan(first) && !isnan(second) && (act == '-' || act == '+')) 

if want invert condition, be

if ( !(!isnan(first) && !isnan(second) && (act == '-' || act == '+'))) 

which equivalent to

if ( isnan(first) || isnan(second) || (act != '-' && act != '+')) 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -