This method takes an integer as its param, and will return the appropriate suffix string, ie: 1st, 2nd, 498th, etc.
function appendNumericSuffix(int) {
suffix=""; suffixArray = new Array ('th','st','nd','rd');
int = int + ''; arrayIndex = int.charAt(int.length-1);
int.length<=2?lastNum = int.charAt(arrayIndex):lastNum = int.substring(int.length-2,int.length);
if(lastNum>3 && lastNum < 21) {
suffix="th";
} else {
arrayIndex<4?suffix=suffixArray[arrayIndex]:suffix="th";
}
return int + '' + suffix + '' ;
}
slayer.office home