So I wrote this String function to add stuff to each word in a sentence
String.prototype.addStuff = function() {
return this.replace(/ /g, "-stuff ") + "-stuff"
}
I was told there was a way to invoke this function on a string without using parentheses. Anyone know how?
I tried wrapping the function declaration in parentheses and adding a pair to the end:
String.prototype.liu = (function() {
return this.replace(/ /g, "-liu ") + "-liu"
})();
But that didn't work :/