Reversing a String : String : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » String »

 

Reversing a String




<html>
<head>
<SCRIPT LANGUAGE="JavaScript1.2">

function revString(str) { 
   var retStr = ""
   for (i=str.length - ; i > - ; i--){ 
      retStr += str.substr(i,1)
   
   return retStr; 

</head>
<body>
<form>
<INPUT type=button value="Reverse String" 
   onClick="document.theForm.results.value = revString(document.theForm.inStr.value)";>
</form>
</body>
</html>
           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» String