javascript - if statement with more than one condition -


i need check 3 conditions,

sheet_exists = 1 recalc = 1  qty_total , new_qty_total not equal 

the if statement works if first 2 arguments used:

if(sheet_exists === 1 && recalc === 'yes'){    //do } 

but when try add 3rd argument fails, actions in if statement ignored. i've tried:

if((sheet_exists === 1) && (recalc === 'yes') && (qty_total !== new_qty_total)){    //do } 

and:

if(sheet_exists === 1 && recalc === 'yes' && (qty_total !== new_qty_total)){     //do } 

and:

if(sheet_exists === 1 && recalc === 'yes' && qty_total !== new_qty_total){     //do  } 

where going wrong?

considering happy behavior of first 2 conditions, , not last one, problem must in last one.

pay attention, qty_total !== new_qty_total return true when value or type of qty_total , new_qty_total different.

if 1 integer 100 , other string '100' condition evaluates true because differ on data type. if both integers return false, because neither value nor type different.

to make sure comparison works ok, make sure both variables same data type.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -