Last active
April 20, 2018 10:09
-
-
Save arkadylukashov/eeaf89c91fce012f576ebcb093e9f4b1 to your computer and use it in GitHub Desktop.
Number ending
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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