Created
July 13, 2017 19:18
-
-
Save rustamgarifulin/e92be3d7d02b26368a165a19354cba07 to your computer and use it in GitHub Desktop.
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
const numfix = (n, t) => t[ | |
(n %= 100, 20 > n && n > 4) ? 2 | |
:[2,0,1,1,1,2][ (n %= 10, n < 5) ? n : 5] | |
] | |
; | |
const a = ['день','дня','дней']; | |
console.log(numfix(1, a)); // день | |
console.log(numfix(2, a)); // дня | |
console.log(numfix(5, a)); // дней |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment