0

How can i check array match string for example

var blocklist = ['jack','mark','jhon','fox'];

var str = "xxxxxxxxxxjackxxxxxxxxx";

How can i check for var str that not match array blocklist?

naham 3k
  • 91
  • 6

1 Answers1

0

You could find the string by using Array#includes.

var blocklist = ['jack', 'mark', 'jhon', 'fox'],
    str = "xxxxxxxxxxjackxxxxxxxxx",
    result = blocklist.find(s => str.includes(s));

console.log(result);
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392