View Single Post
Old 11-20-2003, 06:52 PM   PM User | #11
jsWalter
New Coder

 
Join Date: Nov 2003
Location: Chicago, IL
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
jsWalter is an unknown quantity at this point
Quote:
Code:
function num_abbrev_str(num) {
var len = num.length, last_char = num.charAt(len - 1), abbrev
if (len == 2 && num.charAt(0) == '1') {
abbrev = 'th'
} else {
if (last_char == '1') {
abbrev = 'st'
} else if (last_char == '2') {
abbrev = 'nd'
} else if (last_char == '3') {
abbrev = 'rd'
} else {
abbrev = 'th'
}
}
return num + abbrev
}
This will not work with 11, 12, and 13...

need to add...
(make this the first check)

Code:
 
if  ( (num == '11') || (num == '12') || (num == '13') ) {
abbrev = 'th'
} else if...
jsWalter
jsWalter is offline   Reply With Quote