andy-h
2/6/2014 - 8:48 PM

Get the ordinal indicator of a number (English only)

Get the ordinal indicator of a number (English only)

function ordinalOf(num){
	var n;
	return ((n = num%100) === 11 || n === 12 || n === 13) ? "th" : ((n = num%10) === 1) ? "st" : (n === 2) ? "nd" : (n === 3) ? "rd" : (num%1 === 0) ? "th" : "";
}