/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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);