Im trying to get a string that startsWith "O-" out of a string[] but don’t know how
const players = Array.from(world.getPlayers())
for (let player of players) {
let tags = player.getTags() // tags is the Array
let tag = tags.startsWith("O-")
}
>Solution :
Assuming player.getTags returns an array of strings, and you only want a single tag, you can use the find method, and pass to it a function that checks if a tag starts with "O-".
let tag = tags.find(t => t.startsWith("O-"))