Javascript and testing for 3 values?

What’s the best way to test for three values in Javascript, in other words, what I want to do is this:

if (variable1==true  variable2==true  variable3==false) {
  then do this;
  }

But AFAIK you can’t do this in Javascript. So what I’ve been doing is this:

if (variable1==true  variable2==true) {
  if (variable3==false){
    then do this;
  }}

But that seems clumsy to me. Is there a better way?

The former should be fine. Doesn’t it work?

You can always add brackets if you need to group a set of expressions:

if((variable1 == true  variable2 == true)  variable3 == false)
{ ... }

Also note that since the variable is a boolean it already represents a true/false value so theres no need to do a comparison, simply write:

if (variable1  variable2  !variable3) {
  then do this
}

Well silly me :sweat_smile: I searched every reference on Javascript I could find and couldn’t find anywhere that said that it was possible so I assumed it wasn’t. I’ll give it a go, thanks Neil!

Edit: Thanks Talzor, that’s very clean.