Created
July 24, 2015 10:07
-
-
Save JavaScript-Packer/5acc0a3f32dec23950ff to your computer and use it in GitHub Desktop.
Make numbers show like 1st, 2nd, 3rd or (n)th
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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