Skip to content

Instantly share code, notes, and snippets.

@hughes
Created June 4, 2012 21:18
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 hughes/2870897 to your computer and use it in GitHub Desktop.
Save hughes/2870897 to your computer and use it in GitHub Desktop.
// Returns the orginal of an integer
function getOrdinal(n) {
var s = ["th","st","nd","rd"];
var v = n % 100;
return (s[(v - 20) % 10] || s[v] || s[0]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment