-
-
Save Rachind/6569c853a5fbc99f7201a5aa463181a6 to your computer and use it in GitHub Desktop.
JavaScript russian plural function
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 getNoun(number, one, two, five) { | |
let n = Math.abs(number); | |
n %= 100; | |
if (n >= 5 && n <= 20) { | |
return five; | |
} | |
n %= 10; | |
if (n === 1) { | |
return one; | |
} | |
if (n >= 2 && n <= 4) { | |
return two; | |
} | |
return five; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment