npm.io
2.1.0 • Published 3 years ago

nouns-number

Licence
MIT
Version
2.1.0
Deps
0
Size
2 kB
Vulns
0
Weekly
0

nouns-number

A simple selection of the noun case by number

npm npm npm

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 минуты