Is there a better way of checking if a word exists in an array of strings without including Punctuation Marks?
what I have tried,
const sArray=['Lorem','Ipsum','typesetting-','industry.','Ipsum?','has' ]
console.log(sArray.toString().replaceAll(".","").includes("industry")) //true
console.log(sArray.includes("industry")) //false
sArray.some(e => e.includes("industry"))
. Pay attention to the fact that theincludes
here isString.prototype.includes
, notArray.prototype.includes
.Array.prototype.find()
(const foundItem = sArray.find(e => e.includes("industry")); if (foundItem !== -1) { /* manipulate the string */ }
)