/ Published in: JavaScript
1 -> 1st, 2 -> 2nd ...
Expand |
Embed | Plain Text
Number.prototype.ordinal = function () { return this + ( (this % 10 == 1 && this % 100 != 11) ? 'st' : (this % 10 == 2 && this % 100 != 12) ? 'nd' : (this % 10 == 3 && this % 100 != 13) ? 'rd' : 'th' ); }
You need to login to post a comment.
