View Single Post
Old 11-25-2003, 11:13 PM   PM User | #20
RoyW
Regular Coder

 
Join Date: Jun 2002
Location: Atlanta, GA.
Posts: 313
Thanks: 0
Thanked 0 Times in 0 Posts
RoyW is an unknown quantity at this point
Hi jsWalter,
You beat me to it. I was going to do it in one step
Code:
function num_abbrev_str(n)
{
 return n + (( Math.floor((n%100)/10) == 1) ? "th" : ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"][n%10]);
}
but it is essentially the same thing.

I just noticed that liorean is assuming that in boolean expressions true==1

( this % 100 - nModTen != 10 )

Should evaluate to 0 or 1 and then multiply it by a value.

Hmm sneaky
(but maybe a little dangerous)
RoyW is offline   Reply With Quote