Compound if and or statements

Hey guys,

I have been searching for the answer to this but couldn’t find it so i am posting here.

Basically heres what I want to do:

if((A == ON && B == ON) || (C == ON && D == ON)) {
//do this

Essencially I’m trying to pass a compound test. In the above example, both A AND B have to be on OR C AND D have to be on for the If statement to be true. I tried the above but it didn’t seem to work correctly. Is this possible or would i have to write 2 completely separate if statements and “//do this” sections?

Compound conditionals should work fine.

1 Like

Thanks. I will check my code and try again.