2.1.0 • Published 2 years ago
nouns-number v2.1.0
nouns-number
A simple selection of the noun case by number
Syntax
getNoun(array, number)
Params
Param | Type | Required | Description |
---|---|---|---|
array | string[] | true | Array with nouns to select |
number | number | true | the number on which the noun depends |
Examples
import { getNoun } from 'nouns-number'
const array = ['минута', 'минуты', 'минут']
getNoun(array, 1); // -> минута
getNoun(array, 2); // -> минуты
getNoun(array, 5); // -> минут
const count = 2;
const totalMessage = `Прошло всего ${count} ${getNoun(array, count)}`; // -> Прошло всего 2 минуты