Last active
August 23, 2019 15:30
-
-
Save makingthingswork/5b00bc5943c25f3325abcf66d7d49604 to your computer and use it in GitHub Desktop.
Get number as 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
//Returns the number as an ordinal eg. 1st, 2nd, 3rd, 4th etc. | |
var nth = function(o) { | |
return o+(['st','nd','rd'][(o+'').match(/1?\d\b/)-1]||'th'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment