JS determines whether a string contains an item of an array

let arr = ['Hello','hi','John'];
let string1 = "Hello, what`s your name";
arr.every(str => string1.includes(str)) //-> true
|| 
let string1 = "Hi, what`s your name";
arr.some(str => string.includes(str)) //-> false

Guess you like

Origin blog.csdn.net/qq_43585322/article/details/129566270