Closed SkyTech6 closed 3 years ago
const checkWords = (str, word) => {
return str.split(/[\s,\?\,\.!]+/).some(f => word.test(f));
}
let x = "mmorpg are hype";
console.log(checkWords(x, /[mmo|mmos|mmorpg]/));
Ended up going with a specified regex expression due to partial matches with the above function returning true. Plus the compute time is only a 3% difference.
Words like "accommodate" would trigger the includes conditional. Will need to change to something like this