Skip to content

Instantly share code, notes, and snippets.

@arkadylukashov
Last active April 20, 2018 10:09
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 arkadylukashov/eeaf89c91fce012f576ebcb093e9f4b1 to your computer and use it in GitHub Desktop.
Save arkadylukashov/eeaf89c91fce012f576ebcb093e9f4b1 to your computer and use it in GitHub Desktop.
Number ending
function numberEnd(n, titles) {
var cases = [2, 0, 1, 1, 1, 2];
return titles[(n % 100 > 4 && n % 100 < 20) ? 2 : cases[Math.min(n % 10, 5)]];
}
function number_end($n, $titles) {
$cases = array(2, 0, 1, 1, 1, 2);
return $titles[($n % 100 > 4 && $n % 100 < 20) ? 2 : $cases[min($n % 10, 5)]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment