Javascript Array removeValue(int)

Description

Javascript Array removeValue(int)


Array.prototype.removeValue = function(int) {
 var ans = [];/*from   w  w w .j  av  a  2 s .c  o m*/
 var count = 0;
 for (i = 0; i < this.length; i++) {
  if (this[i] !== int) {
   ans.push(this[i]);
  } else if (this[i] === int) {
   count++;
  }
 }
 if (count === 0) {
  return false;
 }
 return ans;
}



PreviousNext

Related