Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function yearDeclension(number, titles) { // склонение именительных рядом с числительным
- cases = [2, 0, 1, 1, 1, 2];
- return number+" "+titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
- }
- console.log( yearDeclension(18, ['год', 'года', 'лет']) );
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement