MV Multiple Note Tag Inputs for If Statement

Hi, I need help figuring out how to get this line of code to work.
To keep things brief, I have a plugin that distributes exp based on enemy level.
The enemy level is set via a note tag.

How can I get an if statement to work with different note tag inputs?

I've tried:

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == "1", "2", "3") {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == ("1", "2", "3")) {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == "1" || "2" || "3") {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == ("1" || "2" || "3")) {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == 1 || 2 || 3) {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == (1 || 2 || 3)) {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == 1, 2, 3) {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == (1, 2, 3)) {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == [1, 2, 3]) {
                    expOut *=.50

JavaScript:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"] == ["1", "2", "3"]) {
                    expOut *=.50

I'm still trying to learn, and I haven't had to do something like this before, so sorry if this looks ridiculous, haha! I feel like the solution is so simple and it's going over my head. 😅
Hi there!
You need to do this, this way:

if(enemy level == 1 || enemy level == 2 || enemy level == 3)... etc...
You're on the right track with the OR operator ||, but your logic is wrong.

Listing values separated by OR will return the first one that is "truthy" - that is, the first one that has value. So when you say, 1 || 2 || 3 the first value, 1, is not 0, so that whole sequence will return 1.

And I don't even know where you got the idea for that syntax with listing the values with commas, that's declaring an array when you put them inside brackets and meaningless when you put them inside parentheses.

I suggest you continue with tutorials, it shouldn't take you long to get to logical operators and this is a very basic usage of them.

To get this working, you need to repeat the entire comparison each time:
Code:
if ( $dataEnemies[enemy._enemyId].meta["EnemyLevel"]==1 || $dataEnemies[enemy._enemyId].meta["EnemyLevel"] ==2 || $dataEnemies[enemy._enemyId].meta["EnemyLevel"] ==3)
Depending upon the flexibility of your notetag in terms of what it accepts, you could also do something like this if you wanted to check against numerous levels without a bunch of or statements:

JavaScript:
const levels = [1, 2, 3, 4, 5];
const level = $dataEnemies[enemy._enemyId].meta["EnemyLevel"];
if (levels.includes(level)) {
    // do whatever
}
In addition to what everyone else has said, another option is to make use of <, <=, >, >= operators to include multiple values in your conditional check. For example:
JavaScript:
if ($dataEnemies[enemy._enemyId].meta.EnemyLevel <= 3)
This would work for any values less than or equal to 3 (which means that 1 or 2 would also be included). However, a potential caveat to be aware of is that it could also work for 0, or -1, or -999999. Depending on your implementation, that might not be an issue. But if you want to be safe, you can make it an explicit range:
JavaScript:
if ($dataEnemies[enemy._enemyId].meta.EnemyLevel >= 1 && $dataEnemies[enemy._enemyId].meta.EnemyLevel <= 3)
I appreciate everyone's input! I was able to get it to work!! 😂
Thank you all so much for helping me out!

Original thread: https://forums.rpgmakerweb.com/threads/multiple-note-tag-inputs-for-if-statement.149734/