If condition: is not one of

Dubz
Mega Sage

Hi All,

Hopefully an easy question; i need to script an if condition to say active = true and state is not 6, 7 or 8. What's the best way to write this, can i comma-separate options or do i need to write out each state individually? I tried option 1 below and it didn't work so not really sure where to go from here.

if(active = true && state != 6 && state != 7 && state != 8){

//stuff here

}

if(active = true && state != 6, 7, 8){

//stuff here

}

if(active = true && state != 6 || 7 || 8){

//stuff here

}

1 ACCEPTED SOLUTION

vinothkumar
Tera Guru

Hi David,



Try add one more bracket before state and it will work.



if(active = true && (state != 6 && state != 7 && state != 8)){  


//stuff here  


}  


View solution in original post

6 REPLIES 6

vinothkumar
Tera Guru

Hi David,



Try add one more bracket before state and it will work.



if(active = true && (state != 6 && state != 7 && state != 8)){  


//stuff here  


}  


Srvs
Kilo Guru

Hi David,



in your question , you mentioned as OR condition and in code you are trying with and(&&),



the best way you can do is && or ! condition, like Akash and Vinoth replies are helpful.



Regards


Bitra