Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Created July 24, 2015 10:07
Show Gist options
  • Save JavaScript-Packer/5acc0a3f32dec23950ff to your computer and use it in GitHub Desktop.
Save JavaScript-Packer/5acc0a3f32dec23950ff to your computer and use it in GitHub Desktop.
Make numbers show like 1st, 2nd, 3rd or (n)th
function humanizer(e) {
if (e % 100 >= 11 && 13 >= e % 100) {
return e + "th";
}
switch (e % 10) {
case 1:
return e + "st";
case 2:
return e + "nd";
case 3:
return e + "rd";
}
return e + "th";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment