Skip to content

Instantly share code, notes, and snippets.

@siman
Created September 27, 2019 18:02
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 siman/1c65ae645b595cbd2890205adf51a066 to your computer and use it in GitHub Desktop.
Save siman/1c65ae645b595cbd2890205adf51a066 to your computer and use it in GitHub Desktop.
function pluralize(count: number | BN, singluarText: string, plularText?: string) {
count = typeof count !== 'number' ? count.toNumber() : count;
const plural = () => !plularText ? singluarText + 's' : singluarText;
const text = count === 1 ? singluarText : plural()
return <><b>{count}</b> {text}</>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment