Skip to content

Instantly share code, notes, and snippets.

@domosedov
Created February 22, 2023 11:36
Show Gist options
  • Save domosedov/4785ea9a3597dbcd0bb3bc154ffe73a2 to your computer and use it in GitHub Desktop.
Save domosedov/4785ea9a3597dbcd0bb3bc154ffe73a2 to your computer and use it in GitHub Desktop.
resolve plural form
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