Check all actors name

Hi,
Let's say I have a huge number of actors (idk 100), and I want to check if among them there is one actor called "x"; there is a way to do this without compile 100 conditional branches?
Thank you
Quickest way is to use a for loop. I'm not too familiar with JavaScript's syntax, but that should be about right. Just put that in the script box and execute whatever command you want.
for (let i = 0; i < 100; i++) {
if($gameActors.name == "x"){
//Do stuff.
}
}
Quickest way is to use a for loop. I'm not too familiar with JavaScript's syntax, but that should be about right. Just put that in the script box and execute whatever command you want.
for (let i = 0; i < 100; i++) {
if($gameActors.name == "x"){
//Do stuff.
}
}

The check for name is wrong, also starts at 1.
Code:
for (let i = 1, l = $gameActors._data; i < l.length; ++i) {
    if (l[i]._name === "insert name") {
    stuff
    }
}
Ah, whoops. I did say I didn't know the syntax too well, LOL.

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/check-all-actors-name.119882/