Last active
June 24, 2019 13:52
-
-
Save kitcat-dev/17d3df5a7af8fe8e478f5a71e11a121f to your computer and use it in GitHub Desktop.
Склонения числительных
This file contains hidden or 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
| function declOfNum(number, titles) { | |
| const cases = [2, 0, 1, 1, 1, 2]; | |
| let i; | |
| if (number % 100 > 4 && number % 100 < 20) i = 2; | |
| else if (number % 10 < 5) i = cases[number % 10]; | |
| else i = 2; | |
| return titles[i]; | |
| } | |
| // usage | |
| for (var i = 0; i < 35; i++) { | |
| console.log(`${i} ${declOfNum(i, ['банк', 'банка', 'банков'])}`); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment