Skip to content

Instantly share code, notes, and snippets.

@Sapphiron532
Forked from ivan1911/declofnum.js
Created May 30, 2016 12:35
Show Gist options
  • Save Sapphiron532/858c378e938aade0442d0250161c7edf to your computer and use it in GitHub Desktop.
Save Sapphiron532/858c378e938aade0442d0250161c7edf 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