UNPKG

just-pluralize

Version:

A simple singularized tool for all your pluralization problems.

9 lines (8 loc) 259 B
module.exports.pluralize = (word, count = 0, pluralWord) => { if (!!word) { const pluralizedWord = count <= 1 ? word : pluralWord || `${word}s`; return pluralizedWord; } else { throw new Error("Oops you didn't pass the singular word"); } };