Return to Snippet

Revision: 23863
at February 15, 2010 22:02 by alvincrespo


Initial Code
var pString:String = "hello";
var rString:String = "";

/*
	h	e	l	l	o
	0	1	2	3	4	- position of the letter
	1 	2	3	4	5	- length of string
						- initial length is 5
						- substr("position of letter", "get one letter")
*/

for(var i:int = pString.length-1; i>=0; i--){
	rString += pString.substr(i,1);
}

trace("String: " + pString);

trace("Reverse String: " + rString);

Initial URL


Initial Description


Initial Title
How to Reverse a String

Initial Tags
actionscript

Initial Language
ActionScript 3