cancel
Showing results for 
Search instead for 
Did you mean: 

How to write if statement with multiple operators ?

Frequent Contributor

How to write if statement with multiple operators ?

Hi,

 

is there a better way to re-write this statement?

 

a ='1a'
b ='2a'
c = '3a'
d= '4a'
e ='5a'

if (a=='1a' || b == '2a' || c =='3a') && (d == '4a'){
assert e =='5a'

 

Thank you

 

 

4 REPLIES 4
Community Hero

Re: How to write if statement with multiple operators ?

It is not possible to comment unless some one wears your hat.

Please explain the issue you are facing.


Regards,
Rao.
Community Leader

Re: How to write if statement with multiple operators ?

Yo!

 

Use triple === to compare values.

 

I am comparing the multiple values like this:

 

if ((val === 2 && val2 === 0) || (val3 === 2 && val4 === '')) {
   // some Code
}
Frequent Contributor

Re: How to write if statement with multiple operators ?

Thanks Wamboo.

 

 

Community Leader

Re: How to write if statement with multiple operators ?

Cheers!

 

If You need any help, write another post Smiley Happy

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors