Javascript Array countCattle(cattle)
// After/*w w w. java 2 s . c o m*/ Array.prototype.countCattle = function(cattle){ var number = 0; for(var i = 0; i < this.length; i ++){ if(this[i].type == cattle){ number ++ ; } } return number; };