Nodejs String Delete delete()

Here you can find the source of delete()

Method Source Code

// http://www.codewars.com/kata/ruplesjs-number-2-string-delete

String.prototype.delete = function () {  
  var str = this.toString();
  
  for(let i = 0; i < arguments.length; i++) {
    switch(typeof arguments[i]) {
      case 'string':    
        str = str.replace(new RegExp(arguments[i], 'g'), "");
        break;//from   ww w  . ja v  a2 s. com
      case 'object':
        str = str.replace(arguments[i], "");    
        break;    
    }     
  }  
  
  return str;  
}

Related

  1. delete()
    String.prototype.delete=function() {
      for(var e in arguments) {
        console.log(typeof arguments[e]);
        this.replace(arguments[e],'');
        console.log(this);
      return this.valueOf();
    console.log("Hello World123".delete(/h/gi, /[0-9]/g));
    ...
    
  2. delete(remove)
    String.prototype.delete = function(remove) {
     var result= '';
     for(var i=0;i<this.length;i++) {
        for (var j=0;j<remove.length;j++) {
        if(this.charAt(i) != remove.charAt(j)) {
            result += this.charAt(i)
     return result
    console.log("Hello World".delete('o'))