A relatively straight forward issue I think, however I'm having a few issues getting it right.
I've got an array of strings and a sentence. If any of the words in the array appear in the sentence, remove them.
const products = ["premium t-shirt", "t-shirt", "sweatshirt", "baseball tee", "v-neck t-shirt", "long sleeve t-shirt", "raglan baseball tee", "pullover hoodie", "tank top", "zip hoodie",
"hoodie", "shirt", "tee", "tshirt"];
const name = "I'd Rather Be Beekeeping Save The Bees Honey Bee Beehive Zip Hoodie T-Shirt".toLowerCase();
let strippedName;
products.forEach(p => {
if(name.includes(p)) strippedName = name.replace(p, "");
});
The above removes the word shirt, but not t-shirt. Theres also the issue of it needed to loop around on the strippedName variable rather tan the name.
I'm not sure if theres a better way to do this though?
.toLowerCase()