MZ Why isn't my script working?

I'm working on an evolution mechanic for my game (actually a fan remake of an old, no longer existing iOS game called Morphs) but the script for it isn't working. I'm pretty sure the culprit is the part where it checks the actor's class. This is the script:
JavaScript:
for (var i = 0; i < $gameParty.members().length; i++) {
  // Checks if selected morph is the Prime class
  if($gameParty.members().isClass($dataClasses[0])) {
    // Checks if morph is at least level 2
    if($gameParty.members().level >= 2) {
      // Ember evolution criteria: Fire greater than all other elements
      if($gameParty.members().mat >= $gameParty.members().mdf && $gameParty.members().mat >= $gameParty.members().luk) {
        $gameParty.members().changeClass(2, true);
        $gameMessage.add("\N[1] morphed into an Ember!");
      }
      // Pebble evolution criteria: Earth greater than all other elements
      if($gameParty.members().mdf >= $gameParty.members().mat && $gameParty.members().mdf >= $gameParty.members().luk) {
        $gameParty.members().changeClass(3, true);
        $gameMessage.add("\N[1] morphed into a Pebble!");
      }
      // Dew evolution criteria: Water greater than all other elements
      if($gameParty.members().luk >= $gameParty.members().mat && $gameParty.members().luk >= $gameParty.members().mdf) {
        $gameParty.members().changeClass(4, true);
        $gameMessage.add("\N[1] morphed into a Dew!");
      }
    }
  }
}
How do I get the isClass function to work? Do I have to use a number? A string? An actual class variable, somehow? Any help is appreciated!
I recommend using the Code tag (which looks like this </>) when posting your code for people to look through; it makes it a lot easier to read.

A couple things first: $gameParty.members() returns an array, and $dataClasses[0] is not defined - database entries start with the id 1.

So, for example, to see if the class of party member 0 (the leader) is of type 1, you'd need:
Code:
$gameParty.members()[0].isClass($dataClasses[1])

Given that you have a for loop, it looks like you'd like to iterate through all members of the party, but you don't actually use the variable i to select a party member as far as I can tell. You probably want something like this:
Code:
for (var i = 0; i < $gameParty.members().length; i++) {
  const member = $gameParty.members()[i];
  if (member.isClass($dataClasses[1])) {
    // so on and so forth
  }
}
How do I get the isClass function to work?
You're calling it correctly. The problem is, class 0 doesn't exist, so it always returns false. Class IDs start at 1. Also, you haven't specified which member to check – members().isClass does not exist, you want members()[0].isClass or members()[i].isClass.

To make things simpler, I'd actually recommend writing your loop header like this:

JavaScript:
for(let member of $gameParty.members()) {
    if(member.isClass($dataClasses[1])) ...
}

Then everywhere you wrongly wrote $gameParty.members(). would be replaced by just member..
Thank you, everyone, my script finally works!

Original thread: https://forums.rpgmakerweb.com/threads/why-isnt-my-script-working.181138/