|
|
|
|
|
| ||
|
n99creations
View Snippet | ||
|
ordinalise function
Creator: nathan99 Date Added: May 14, 2007 Rating: 100% (2 of 2 Votes) Parameters number:Number - The number that you want to be ordinalised. The function does not directly modify any variables. Description: Reads the number parameter and converts it into an ordinalised String (ie: 1st, 2nd, 3rd.. 13th, etc..). Returns String - A String value, the ordinalised value of number. Example The following demonstrates the usage of the function over the main conditions, displaying every possible result. (Let me know id I missed any exceptions) Actionscript Code:
function ordinalise(number:Number):String {
var tmp:String = String(number); if (tmp.substr(-2, 2) != "13" && tmp.substr(-2, 2) != "12" && tmp.substr(-2, 2) != "11") { if (tmp.substr(-1, 1) == "1") { var end:String = "st"; } else if (tmp.substr(-1, 1) == "2") { var end:String = "nd"; } else if (tmp.substr(-1, 1) == "3") { var end:String = "rd"; } } if (!end) { var end:String = "th"; } return tmp+end; } trace(ordinalise(21));// Outputs 21st trace(ordinalise(102));// Outputs 102nd trace(ordinalise(33));// Outputs 33rd trace(ordinalise(13));// Outputs 13th trace(ordinalise(11));// Outputs 11th trace(ordinalise(112));// Outputs 112th trace(ordinalise(1));// Outputs 1st ![]()
There are no comments to display.
iTunes Coverflow (609 votes) iTunes Coverflow... (277 votes) Mac OSX Tsunami ... (113 votes) Rotating Menu (47 votes) 3D Rotating Tree (33 votes) BitmapData fade ... (18 votes) Water ripples wi... (18 votes) iTunes Coverflow... (18 votes) Vertical Menu (16 votes) Sliding menu (14 votes)
shuffle (Array.s... (6 votes) _recordDownloadS... (4 votes) Pagination (3 votes) ordinalise funct... (2 votes) distanceBetween ... (1 votes) Here at n99creations, we love donations =] |