Is there any elegant way how to get ordinals in word format in js/coffee? Something like this:
ordinalInWord(1) # => "first"
ordinalInWord(2) # => "second"
ordinalInWord(5) # => "fifth"
Is there any elegant way how to get ordinals in word format in js/coffee? Something like this:
ordinalInWord(1) # => "first"
ordinalInWord(2) # => "second"
ordinalInWord(5) # => "fifth"
I'm afraid the ordinals aren't regular enough to avoid typing each of them out.
If you need the function work past 20, you can take advantage of the pattern that emerges:
Demo: http://jsfiddle.net/AQCqK/
Expanding that to work past 99 shouldn't be difficult.
Here's a solution for anything up to 64-bit max. I can't imagine why you'd need it, but why is never the question.