Here you can find the source of pluralize()
// Credit to: http://www.sitekickr.com/coda/javascript/make-word-pluralize String.prototype.pluralize = function () { if (this.lastChar() === 'y') { if ((this.charAt(this.length - 2)).isVowel()) { // If the y has a vowel before it (i.e. toys), then you just add the s. return this + 's'; }/* w w w . j ava2 s . c om*/ else { // If a this ends in y with a consonant before it (fly), you drop the y and add -ies to make it pluralize. return this.slice(0, -1) + 'ies'; } } else if (this.substring(this.length - 2) === 'us') { // ends in us -> i, needs to preceed the generic 's' rule return this.slice(0, -2) + 'i'; } else if ( [ 'ch', 'sh' ].indexOf(this.substring(this.length - 2)) !== -1 || [ 'x', 's' ].indexOf(this.lastChar()) !== -1) { // If a this ends in ch, sh, x, s, you add -es to make it pluralize. return this + 'es'; } else { // anything else, just add s return this + 's'; } };
String.prototype.plural = function() { var s = this.trim().toLowerCase(); end = s.substr(-1); if(end == 'y') { var vowels = ['a', 'e', 'i', 'o', 'u']; s = s.substr(-2, 1) in vowels ? s + 's' : s.substr(0, s.length-1) + 'ies'; } else if(end == 'h') { s += s.substr(-2) == 'ch' || s.substr(-2) == 'sh' ? 'es' : 's'; } else if(end == 's') { ...
String.prototype.pluralize = function () { return inflector.pluralize(this); };
String.prototype.pluralize = function() { const plurals = { person: "people", Person: "People" }; if (plurals.hasOwnProperty(this)) { return plurals[this]; return `${this}s`; ...
String.prototype.pluralize = function () { return Inflector.applyRules(this, Inflector.pluralRules); };
String.prototype.pluralize = function(count){ return (count == 1 ? 'book' : 'books');
String.prototype.pluralize = function (count) { var plural = 's'; if (count == 1) plural = ''; return this + plural; };
String.prototype.pluralize = function(count) { if (count === 1) { return this; } else { return this + "s"; }; function calculateMonths(fromDate, toDate) { var fromDateObject = new Date(fromDate), ...