MV Simple Permadeath Script Help

I'm thinking of making my own first written plugin js script for my game which is a permadeath but as a guy who has no javascript experience but with a little bit of coding knowledge I would ask a few very simple questions:

How can I check if one specified actor from the game data has a specified state id at the overworld?

(could it be that I need to create a variable then assign it on forEach() statement first right?)

thnks
Hi there!
I believe you want to check this with javascript, right?

So this will return an array of all the party members:
$gameParty.members()

To check all of them, you can use them for each. But if you want to do anything with the party members themselves, I advise you to use a for loop instead.
JavaScript:
for(const member of $gameParty.members()){
    if(member.isStateAffected(stateId)){
    // do your thing
    }else{
    //do other thing
    }
}

The for each will look like this:
JavaScript:
$gameParty.members().forEach( member =>{
if(member.isStateAffected(stateId)){
    // do your thing
    }else{
    //do other thing
    }
})

Original thread: https://forums.rpgmakerweb.com/threads/simple-permadeath-script-help.138567/