I have a function that can remove words from a string. It is :
var removeFromString = function(oldStr, fullStr) {
return fullStr.split(oldStr).join('');
};
I use it like this :
console.log( removeFromString("Hello", "Hello World") ); // World
console.log( removeFromString("Hello", "Hello-World") ); // -World
But the main problem :
var str = "Remove one, two, not three and four";
Here we have to remove "one", "two" & "four". This can be done by :
var a = removeFromString("one, two,", str); // Remove not three and four
var b = removeFromString("and four", a); // Remove not three
console.log(b); // Remove not three
In the above example, I had to use the function twice. I want it to be something like this :
var c = removeFromString(["one, two," , "and four"], str); // Remove not three
console.log(c); // Remove not three
Yes, I actually want to upgrade the removeFromString function ! How can I do that ?