pluralize
Returns the singular or plural form of the word based on the input number, using an optional dictionary if supplied.
- Use a closure to define a function that pluralizes the given
word
based on the value ofnum
. - If
num
is either-1
or1
, return the singular form of the word. - If
num
is any other number, return theplural
form. - Omit the third argument,
plural
, to use the default of the singular word +s
, or supply a custom pluralizedword
when necessary. - If the first argument is an
object
, return a function which can use the supplied dictionary to resolve the correct plural form of the word.