Skip to content

Instantly share code, notes, and snippets.

@tesmen
Created November 23, 2015 13:21
Show Gist options
  • Save tesmen/b7d66166ef2b95ddab7f to your computer and use it in GitHub Desktop.
Save tesmen/b7d66166ef2b95ddab7f to your computer and use it in GitHub Desktop.
function declension(amount, words) {
var digit = (Number(amount) > 20) ? Number(amount) % 10 : Number(amount);
if (digit >= 5 || digit == 0) {
return words[2]
}
if (digit >= 2) {
return words[1]
}
return words[0];
}
function plural(amount, words) {
return amount + ' ' + declension(amount, words);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment