Home > Back-end >  How to check if one string ONLY contains items of an array?
How to check if one string ONLY contains items of an array?

Time:09-17

Yo guys, I have an array of the alphabet and I wanna check whether a string only contains the items of this alphabet. If not, my bot kick a player from a game. I managed to write this script:

var letters =
    "a b c d e f g h i j k l m n o p q r s t u v w x y z";
  var arrayLetters = letters.split(/  /);
  var allLetters = arrayLetters.map((x) => x.toLowerCase());

  if (!allLetters.some((x) => player.name.includes(x)) {
    room.kickPlayer("Your name can't have strange fonts");
  }

Actually, this works but with names that doesn't contain a letter at all.

For example,

  • Related