MV Checking a variable against multiple variables

So I'm trying to make an if statement to see if a variable equals any of a bunch of variables. I had thought it would be something like this:


Code:
if ($gameVariables.value(629) == $gameVariables.value(602) || $gameVariables.value(604) || $gameVariables.value(606) || $gameVariables.value(608) || $gameVariables.value(610) || $gameVariables.value(612) || $gameVariables.value(614) || $gameVariables.value(616))

But this doesn't work.

Thoughts?
that is because you didn't make complete comparisons.

and you can ONLY compare two values.

the correct code would be
Code:
if (a===b || a===c || a===d)
and so on.

please note the use of tripe = as that is needed in this case with javascript in addition to comparing multiple times a with the other variable

There is another way using an array that is shorter, but in that case you would have to form an array of the variables first and that would make the check even more complex, so not advisable for a single line IF
@Andar Thanks for the help!
There is another way using an array that is shorter, but in that case you would have to form an array of the variables first and that would make the check even more complex, so not advisable for a single line IF
That would be

Code:
const isTrue = [$gameVariables.value(a), $gameVariables.value(b), $gameVariables.value(c)].contains($gameVariables.value(x));
if (isTrue) {
    // ...
}

I prefer this style over a bunch of == comparisons.

Original thread: https://forums.rpgmakerweb.com/threads/checking-a-variable-against-multiple-variables.131399/