Nodejs Array Count countCattle(kind)

Here you can find the source of countCattle(kind)

Method Source Code

Array.prototype.countCattle = function(kind) {
  var numKind = 0;
  for (i in this) {
     if (this[i]["type"] == kind) numKind++;
  }/*  w ww. j av a2 s . co  m*/
  
  return numKind;
};

Related

  1. countCattle( kind )
    Array.prototype.countCattle = function ( kind ){
      var numKind = 0;
      for(var i = 0; i<this.length; i++){
        if(this[i].type == kind){
          numKind++;
      return numKind;
    };
    ...
    
  2. countCattle(cattle)
    Array.prototype.countCattle = function(cattle){
      var number = 0;
      for(var i = 0; i < this.length; i ++){
        if(this[i].type == cattle){
          number ++ ;
      return number;
    };
    ...
    
  3. countCattle(kind)
    Array.prototype.countCattle = function(kind) {
      var numKind = 0;
      for (var i = 0; i<this.length; i++) {
        if (this.type == kind){
          numKind++;
      return numKind;
    };
    ...
    
  4. countCattle(kind)
    Array.prototype.countCattle = function(kind) {
      var numKind = 0;
      for (var i = 0; i < this.length; i++) {
        if (this[i].type == kind) {
          numKind++;
      return numKind;
    };
    ...
    
  5. countCattle(kind)
    Array.prototype.countCattle = function (kind) {
      var numKind = 0;
      for (var i = 0; i < this.length; i++) {
        if (this[i].type == kind) {
          numKind++
      return numKind
    var canyonCows = [
      { name: "Bessie", type: 'cow', hadCalf: 'Burt'},
      { name: "Bessie", type: 'bull', hadCalf: 'Burt'},
      { name: "Bessie", type: 'cow', hadCalf: 'Burt'},
      { name: "Bessie", type: 'cow', hadCalf: 'Burt'},
      { name: "Bessie", type: 'calf', hadCalf: null},
    ]
    console.log(canyonCows.countCattle('cow'))
    
  6. calculateCount()
    Array.prototype.calculateCount = function() {
        return this.length;
    };
    var a = ["1", "2"];
    var count = a.calculateCount();
    console.log(count);
    
  7. countForBreeding()
    Array.prototype.countForBreeding = function() {
      var numToBreed = 0;
      for (var i = 0; i < this.length; i++) {
        if (this[i].noCalvesYet()) {
          numToBreed++;
      return numToBreed;
    };
    ...
    
  8. countItem(item)
    Array.prototype.countItem = function (item) {
            return this.filter(function (i) {
                return i === item
            }).length;
    };
    
  9. countOf(pValue)
    Array.prototype.countOf = function (pValue){
        var count   = 0;
        var lArray  = this || [];
        var lLength = lArray.length
        for (var i = 0 ; i < lLength; i++){
            if (lArray[i] == pValue){
                count++;
        return count;