Skip to content

Instantly share code, notes, and snippets.

@shchegol
Forked from realmyst/gist:1262561
Last active December 20, 2018 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shchegol/30576c03e544bd9ef1e14cbefb6754f6 to your computer and use it in GitHub Desktop.
Save shchegol/30576c03e544bd9ef1e14cbefb6754f6 to your computer and use it in GitHub Desktop.
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment