Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gearmobile/98978a987b5336b52a3bda664e556e6b to your computer and use it in GitHub Desktop.
Save gearmobile/98978a987b5336b52a3bda664e556e6b to your computer and use it in GitHub Desktop.
Склонение существительных
// methods
getNoun (number, singular, few, plural) {
number = Math.abs(number)
number %= 100
if (number >= 5 && number <= 20) {
return plural
}
number %= 10;
if (number == 1) {
return singular
}
if (number >= 2 && number <= 4) {
return few
}
return plural
}
// template
<p>{{ count + ' ' + getNoun(count, 'окно', 'окна', 'окон') }}</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment