Here’s a handy little code snippet. Need to append the placement of a number? Use this!
private function getNth (num:Number):String
{
var qn:int = ((num%100) / 10);
var rn:int = num % 10;
var suffix:String = "th";
if (qn != 1) {
switch (rn) {
case 1: suffix = "st"; break;
case 2: suffix = "nd"; break;
case 3: suffix = "rd"; break;
}
}
return num + suffix;
}
Leave a Reply
You must be logged in to post a comment.