Javascript Array numberOfOccurrences(target)

Description

Javascript Array numberOfOccurrences(target)


Array.prototype.numberOfOccurrences = function(target) {
  for(var i =0;i<this.length;i++){
    var x = this.filter(function(b){return b === target}).length
  }/*from  w w  w.  j  a v  a  2s.  c  o m*/
  return x;
}



PreviousNext

Related