How can I check if the all party members are dead?

Hi all!!

So, in my project, Party might be of 2, 3, 4 etc.

I want something to occur when the whole party is dead, and I dont want to check for any number of party members just check if ALL are dead, I found the .isAllDead() method but Im not that good at programming.

How can I check for this? (Or the correct syntax)

Thanks!!
Couldn't you just run a conditional branch that checks for each party member and if they're inflicted with knock out?
It would be $gameParty.isAllDead() if the method is the correct one.
Yes, but it is exactly what I want to avoid, so the work is cleaner. I just check the gameover scene and it IS $gameParty.isAllDead() but is not working for me. Like if I check for each chacrater, works, but not if I use $gameParty.isAllDead().
Hmm....
After checking it isAllDead is a battle only method. So
Code:
var deadMembers = 0;
for (var i in $gameParty.members()) {
if (!$gameParty.members()[i].isStateAffected(1)) break;
else deadMembers++;
}
if (deadMembers == $gameParty.members().length) perform whatever
Yeah, I was checking it on battle.
But that should work, thanks @Poryg !!
All wortking now. Thanks!

RESOLVED.

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/how-can-i-check-if-the-all-party-members-are-dead.100697/