Nodejs String Pluralize pluralize(val)

Here you can find the source of pluralize(val)

Method Source Code

String.prototype.pluralize = function(val) {
   if (val == 1) {
      return val + " " + this;
   } else if (val == 0 || val >= 2) {
      return val + " " + this + "s";
   }// www  .  j  a  v  a  2  s .c o m
}

Related

  1. pluralize()
    String.prototype.pluralize = function () {
      if (this.lastChar() === 'y') {
        if ((this.charAt(this.length - 2)).isVowel()) {
          return this + 's';
        else {
          return this.slice(0, -1) + 'ies';
      else if (this.substring(this.length - 2) === 'us') {
        return this.slice(0, -2) + 'i';
      else if (
        [
          'ch',
          'sh'
        ].indexOf(this.substring(this.length - 2)) !== -1 ||
          [
            'x',
            's'
          ].indexOf(this.lastChar()) !== -1) {
        return this + 'es';
      else {
        return this + 's';
    };
    
  2. pluralize()
    String.prototype.pluralize = function () {
        return Inflector.applyRules(this, Inflector.pluralRules);
    };
    
  3. pluralize(count)
    String.prototype.pluralize = function(count){
      return (count == 1 ? 'book' : 'books');
    
  4. pluralize(count)
    String.prototype.pluralize = function (count) {
        var plural = 's';
        if (count == 1) plural = '';
        return this + plural;
    };
    
  5. pluralize(count)
    String.prototype.pluralize = function(count) {
      if (count === 1) {
        return this;
      } else {
        return this + "s";
    };
    function calculateMonths(fromDate, toDate) {
      var fromDateObject = new Date(fromDate),
    ...