(Solved) Check if Variable is x, y, or z

Good morning,
I feel like an absolute dummy right now, but I cannot find the solution anywhere for the life of me, and it's probably something very simple that I'm overlooking, but I'm well and truly at a loss right now.

As the title infers, I'm trying to check a Variable for multiple values using a Script. I've tried using || but it doesn't seem to work.

My current (not working) code:
If: Script: $gameVariables.value(9) == 3 || 4 || 5 || 7

I've tried using $gameVariables.value(9) == [x, y, z] and $gameVariables.value(9) == [x || y || z ] in brackets too, but that doesn't work either.

How can I make this work?

---
Context:
The Variable (9) stores the current Map ID. In every map I have a Parallel event that triggers a Common Event before Erasing itself. The Common Event is needed to check the Variable (9) and set the BGM for that specific Map ID (or keeps it the same if applicable, and since maps 3, 4, 5 and 7 are the same 'area', the BGM remains the same, but maps 1, 2 and 6 are different - hence the need to check the Variable).
I hope that makes sense!
Well, you would have to do:
Code:
If: Script: $gameVariables.value(9) == 3 ||  $gameVariables.value(9) == 4 ||  $gameVariables.value(9) == 5 ||  $gameVariables.value(9) == 7

I think alternatively, you may get away with:
Code:
If: Script: $gameVariables.value(9).contains({3, 4, 5, 7})
See below.
For a concise scripted check you can use Conditional Branch -> Script:
JavaScript:
[3, 4, 5, 7].contains($gameVariables.value(9))
You also don't need to use a script at all. Just use Conditional Branches with Elses.
Conditional -> Variable == 3
Else
- Conditional -> Variable == 4
- Else
- - Conditional -> Variable == 5

It takes up more lines than a script call, but that way you're not bottlenecked by your JavaScript knowledge.
alternatively you can use set theory and go
[x, y, z] ∩ [w] => [w]
if [set] contains [w], it'll bring out [w], else, returns [].
the difference being, one is a comparison, the other is an operation.
it won't make much difference in the final product, but it's an alternative worth knowing if you must bend the code to work out a bug.
Wow! Thanks for the responses everyone!
Well, you would have to do:
Code:
If: Script: $gameVariables.value(9) == 3 ||  $gameVariables.value(9) == 4 ||  $gameVariables.value(9) == 5 ||  $gameVariables.value(9) == 7
Thank you, but I was trying to avoid having an insufferably long code haha. 🙂

For a concise scripted check you can use Conditional Branch -> Script:
JavaScript:
[3, 4, 5, 7].contains($gameVariables.value(9))
This is perfect and works beautifully, thank you so much!! 😍

You also don't need to use a script at all. Just use Conditional Branches with Elses.
That was something I briefly considered, but I don't have the patience to do that 🤣

alternatively you can use set theory and go
[x, y, z] ∩ [w] => [w]
Oooh, thanks! That makes sense, and I'll keep a note of that for future reference. 🙂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-check-if-variable-is-x-y-or-z.160530/