Need help creating a skill that spreads poison from one enemy to all others (RPG MAKER MV)

Hey RPG makers, thanks for reading this thread!
I'm still quite new to RPGMaker and have been experimenting with using Javascript in combination with Yanfly plugins to create various skill effects, to various levels of succes haha. (RPG Maker MV)
Right now Im trying to create a skill called gut punch that does the following:

Target an enemy,
Deal X damage to that enemy
if the enemy is poisoned: poison all other enemies.

The idea is that the target vomits over the other enemies spreading his disease to them.
I've tried to write something that I thought would maybe work:

1594992460844.png


I'm quite certain that all the functions I'm using are correct except for the one I try to change the target with:
target = $gameTroop.aliveMembers();

I know how I would be able to apply poison to the main target, but I don't know how to switch targets at some point in the skill phases to then apply poison to the new targets (being all enemies).

If someone could help me out, that would mean the world to me 🙂.
Thanks in advance,
Cubicle
Code:
<Post-Damage Eval>
if (target.isStateAffected(11)) {
  $gameTroop.aliveMembers().forEach(member => { member.addState(11); });
}
</Post-Damage Eval>
Thank you so much man!
It worked, I tried to figure out the syntax and I think I understand 🙂.
the forEach function is something in Javascript and everything else is defined by RPG Maker MV right?
The only thing I'm unsure about is the term 'member,' do you use that term because gameTroop.aliveMembers consists of 'members' or is that also a general term of javascript?
Thanks a lot either way! 🙂

Code:
<Post-Damage Eval>
if (target.isStateAffected(11)) {
  $gameTroop.aliveMembers().forEach(member => { member.addState(11); });
}
</Post-Damage Eval>
You're absolutely correct; forEach is a native function in JavaScript that you can use on any array.

The reason I used "member" was just for a meaningful variable name inside the function block. I could have called it almost literally anything; it's just a way to refer to the current array element inside the function.

Heck, if you wanted you could have done $gameTroop.aliveMembers().forEach(bananasarekindacool => { bananasarekindacool.addState(11); });

Original thread: https://forums.rpgmakerweb.com/threads/need-help-creating-a-skill-that-spreads-poison-from-one-enemy-to-all-others-rpg-maker-mv.124166/