Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Letters Following A Numeral Denoting That It Is An Ordinal Number
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
MIT-LICENSE
Makefile
README.md
index.js
package.json

README.md

ordinal

Letters following a numeral denoting that it is an ordinal number.

Install

npm install ordinal

Usage

Use with numbers or numeric strings. Anything else will throw an exception.

var ordinal = require('ordinal').english;

ordinal(1); //=> '1st'
ordinal(2); //=> '2nd'
ordinal(3); //=> '3rd'
ordinal(4); //=> '4th'

ordinal(11); //=> '11th'
ordinal(12); //=> '12th'
ordinal(13); //=> '13th'

ordinal(21); //=> '21st'
ordinal(22); //=> '22nd'
ordinal(23); //=> '23rd'
ordinal(24); //=> '24th'

To get just the indicator:

var ordinal = require('ordinal').english;
var indicator = ordinal.indicator;

indicator(1); //=> 'st'
indicator(2); //=> 'nd'
indicator(3); //=> 'rd'
indicator(4); //=> 'th'

indicator(11); //=> 'th'
indicator(12); //=> 'th'
indicator(13); //=> 'th'

indicator(21); //=> 'st'
indicator(22); //=> 'nd'
indicator(23); //=> 'rd'
indicator(24); //=> 'th'

Other languages may be supported in the future. Such as:

  • Catalan
  • Croatian
  • Czech
  • Danish
  • Dutch
  • Estonian
  • Faroese
  • Finnish
  • French
  • Galician
  • German
  • Hungarian
  • Icelandic
  • Irish
  • Italian
  • Latin
  • Latvian
  • Malay
  • Norwegian
  • Philippine
  • Polish
  • Portuguese
  • Russian
  • Serbian
  • Slovak
  • Slovene
  • Spanish
  • Swedish
  • Turkish

LICENSE

MIT

Something went wrong with that request. Please try again.