Skip to content

Instantly share code, notes, and snippets.

@michaelschofield
Created February 21, 2014 21:29
Show Gist options
  • Save michaelschofield/9143942 to your computer and use it in GitHub Desktop.
Save michaelschofield/9143942 to your computer and use it in GitHub Desktop.
Simple one-liner to painlessly return ordinals.
function nth(o){return o+([‘st’,’nd’,’rd’][(o+’’).match(/1?\d\b/)-1]||’th’)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment