Javascript String pluralize(val)

Description

Javascript String pluralize(val)


String.prototype.pluralize = function(val) {
 if (val == 1) {//from   w  w w .j  ava  2s  .  c  om
  return val + " " + this;
 } else if (val == 0 || val >= 2) {
  return val + " " + this + "s";
 }
}



PreviousNext

Related