Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created January 13, 2021 19:13
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 andreasvirkus/0677f9c4b14ab25e4b9a7b89d8493f49 to your computer and use it in GitHub Desktop.
Save andreasvirkus/0677f9c4b14ab25e4b9a7b89d8493f49 to your computer and use it in GitHub Desktop.
export const ordinal = (num) => {
const suffix = ['th', 'st', 'nd', 'rd']
const value = val % 100
return val + (suffix[(value - 20) % 10] || suffix[value] || suffix[0])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment