Add state to all actors via script call.

Hello with "$gameActors.actor(actorId).addState(n)" you can add a state to a certain actor.

But that's not what I want. I want to add an state to all actors via script call.

I thought something along the line like this:
$gameParty.members().foreach(addState(1))

could work, but it doesn't, the maker crashes D:

Does someone have an idea?
JavaScript:
for (var i = 0; i < $gameParty.members().length; ++i) {
    $gameParty.members()[i].addState(ID);
}

I believe forEach is a function so you'd wanna do something like
JavaScript:
$gameParty.members().forEach( (el) => el.addState(ID))
That is, if I'm not mistaken. I haven't used forEach function much.
Thank you very much yeah that's how it works.
Oh ok I still have an issue doing what I intended to do, such a bummer.

If I use:

$gameParty.members().forEach( (el) => el.addState($gameVariables.value(1204))

I'll get an error again. Isn't it possible to use an variable as value for the index? Why does the programm crash?
Oh ok I still have an issue doing what I intended to do, such a bummer.

If I use:

$gameParty.members().forEach( (el) => el.addState($gameVariables.value(1204))

I'll get an error again. Isn't it possible to use an variable as value for the index? Why does the programm crash?
Syntax error. You're missing a ) at the end.
JavaScript:
$gameParty.members().forEach( (el) => el.addState($gameVariables.value(1204)))
Oh god damnit you're right. xd

Original thread: https://forums.rpgmakerweb.com/threads/add-state-to-all-actors-via-script-call.148695/