Last active
August 29, 2015 13:56
-
-
Save wizard04wsu/8852198 to your computer and use it in GitHub Desktop.
Get the ordinal indicator of a number (English only)
This file contains 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 ordinalOf(num){ | |
var n; | |
return ((n = num%100) === 11 || n === 12 || n === 13) ? "th" : ((n = num%10) === 1) ? "st" : (n === 2) ? "nd" : (n === 3) ? "rd" : (num%1 === 0) ? "th" : ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment