Created
September 10, 2014 10:39
-
-
Save git-ashish/14d2d9f16309e26bd828 to your computer and use it in GitHub Desktop.
Number - Cardinal to Ordinal
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 getOrdinal(n) { | |
var s=["th","st","nd","rd"], | |
v=n%100; | |
return n+(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