logo@krutoo/utils

plural

Returns right word for given number according to russian language plural rules.

import { plural } from '@krutoo/utils';

const words = ['отзыв', 'отзыва', 'отзывов'];

console.log(0, plural(0, words)); // 0 отзывов
console.log(1, plural(1, words)); // 1 отзыв

console.log(2, plural(2, words)); // 2 отзыва
console.log(3, plural(3, words)); // 3 отзыва
console.log(4, plural(4, words)); // 4 отзыва

console.log(5, plural(5, words)); // 5 отзывов
console.log(10, plural(10, words)); // 10 отзывов