Forum Discussion

_ivanovich_'s avatar
_ivanovich_
Frequent Contributor
5 years ago

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

  • nmrao's avatar
    nmrao
    Champion Level 3
    It is not possible to comment unless some one wears your hat.

    Please explain the issue you are facing.
  • Wamboo's avatar
    Wamboo
    Community Hero

    Yo!

     

    Use triple === to compare values.

     

    I am comparing the multiple values like this:

     

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