Get the correct phrase for an unknown number of items. Ex. "1 item" vs. "2 items"

const roomQuantity = 1
pluralize(roomQuantity, 'room', 'rooms') // returns '1 room'
  • Parameters

    • count: number

      The number of items (typically a variable, not an actual value)

    • singularNoun: string

      Word for a single item

    • pluralNoun: string

      Word for a group of items (or no items)

    Returns string

    Phrase with the count followed by the correct noun