Last active
September 23, 2017 18:37
-
-
Save mfd/024ba2f3ae5e43dfbdd15b3de8a3edc8 to your computer and use it in GitHub Desktop.
cyrillic pluralize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var t = { | |
d: 6, | |
h: 5, | |
m: 23, | |
s: 53 | |
} | |
var pluralize = function(t, e) { | |
var s = void 0 | |
, n = e % 100; | |
return n >= 5 && n <= 20 ? s = t[2] : (n %= 10, | |
s = 1 == n ? t[0] : n >= 2 && n <= 4 ? t[1] : t[2]), | |
s | |
} | |
console.log(t.d + ' ' + pluralize(["День", "Дня", "Дней"], t.d)); | |
console.log(t.h + ' ' + pluralize(["Час", "Часа", "Часов"], t.h)); | |
console.log(t.m + ' ' + pluralize(["Минута", "Минуты", "Минут"], t.m)); | |
console.log(t.s + ' ' + pluralize(["Секунда", "Секунды", "Секунд"], t.s)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment