javascript includes multiple values code example
Example 1: multiple conditions for JavaScript .includes() method
const str = "hi, there"
const res = str.includes("hello") || str.includes("hi") || str.includes('howdy');
console.log(res);
Example 2: javascript includes method getting 'hi' and 'high' problem
const multiSearchOr = (text, searchWords) => (
searchWords.some((el) => {
return text.match(new RegExp(el,"i"))
})
)
multiSearchOr("Chelsey Dietrich Engineer 2018-12-11 Hire", ["che", "hire"])
multiSearchOr("Chelsey Dietrich Engineer 2018-12-11 Hire", ["aaa", "hire"])
multiSearchOr("Chelsey Dietrich Engineer 2018-12-11 Hire", ["che", "zzzz"])
multiSearchOr("Chelsey Dietrich Engineer 2018-12-11 Hire", ["aaa", "1111"])
Example 3: javascript includes method getting 'hi' and 'high' problem
var str = 'hilly';
var value = str.includes('hi');
var value = /\bhi\b/.test(str);