Created
February 22, 2023 11:36
-
-
Save domosedov/4785ea9a3597dbcd0bb3bc154ffe73a2 to your computer and use it in GitHub Desktop.
resolve plural form
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
export function resolvePluralForm(count: number) { | |
const lastNumber = count % 10 | |
const lastNumbers = count % 100 | |
if (lastNumber === 1 && lastNumbers !== 11) return 'one' | |
if (lastNumber > 1 && lastNumber < 5 && (lastNumbers < 10 || lastNumbers > 20)) return 'few' | |
return 'many' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment