Skip to content

Instantly share code, notes, and snippets.

@RiodeJaneiroo
Last active December 1, 2018 12:44
Show Gist options
  • Save RiodeJaneiroo/b336fb149185abefb09216f715b349fe to your computer and use it in GitHub Desktop.
Save RiodeJaneiroo/b336fb149185abefb09216f715b349fe to your computer and use it in GitHub Desktop.
[Склонение числительных javascript] #js #javascript
//Склонение числительных
function declOfNum(n, titles) {
return titles[(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)];
}
/*
use: declOfNum(count, ['найдена', 'найдено', 'найдены']);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment