I'm trying to create a simple prototype in JavaScript that removes a character from a string (like Python's strip). This may well exist already in JavaScript, but I can't find it and this is more of an exercise for me than a replacement for something that already exists.
function strip(chars) {
this.replace(chars,"");
}
String.prototype.strip=strip;
var wrong = "Hellow";
alert(wrong.strip("w"));
When I run this code, the alert says "Undefined". My suspicion is the this. in the function but not sure. I've also made a fiddle here: http://jsfiddle.net/jdb1991/rapxM/
Thanks