Library API
    Preparing search index...

    Function plural

    • Applies a plural suffix to a word if the quantity is not exactly 1 or -1.

      Parameters

      • val: string | number | Record<string, string>

        The numerical quantity or an object containing values

      • word: string

        The singular word

      • plural: string = ...

        The explicitly provided plural form (defaults to word + 's')

      Returns string | ((num: string, word: string) => string)

      The appropriate singular or plural string

      plural(2, 'apple'); // 'apples'