Yesterday I put the following question:
The best way to remove array element by value
Actually the solution found is not valid because.
Let's suppose this use case:
Array.prototype.deleteElem = function(val) {
   var index = this.indexOf(val); 
   if (index >= 0) 
        this.splice(index, 1);
   return this;
}; 
var arr = ["orange","red","black","white","red","red"];
var arr2 = arr.deleteElem("red");
arr2 // ["orange","black","white","red","red"]
As you can see this method delets just one entry, and not all of them equal to "red". How can I fix it? Maybe with recursion?
 
     
    