Pathetic. function ord(x) { x = new String(x); z = x.substr(x.length - 1, 1); od = new Array("st", "nd", "rd"); if ((z == "1") || (z == "2") || (z == "3")) { if ((x == "11") || (x == "12") || (x == "13")) { y = x.concat("th"); } else { y = x.concat(od[z - 1]); } } else { y = x.concat("th"); } return y; }