Weighing in at 368 bytes minified, nTh.js is a javascript micro-library to return ordinal suffixes from integers (ie: 1st, 2nd, 3rd, 7th of 9).
======
nth(4077);
produces 4077th
nth.of(1,3);
produces 1st of 3
<ul>
<li class='nth'>0</li>
<li class='nth'>1</li>
<li class='nth'>2</li>
<li class='nth'>3</li>
<li class='nth'>4077</li>
</ui>
$(function(){
$(".nth").html(function(i,e) {
return nth(e);
});
});
produces:
- 0th
- 1st
- 2nd
- 3rd
- 4077th
======
This library was written by:
-
David Lee Perish @DavidPerish - http://stonyhillsoftware.com
-
Brandon McKinney @pagefold - http://bsstudio.us
-
Gleb Bahmutov @bahmutov - http://glebbahmutov.com
- See Gleb's excellent article on 'Optimizing nTh' here: http://bahmutov.calepin.co/optimizing-nth.html
Any & all contributions are welcomed.
======
nTh.js is free (as in love), and is provided under The MIT License (MIT)