Using a for Loop to Reverse a String : String : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » String »

 

Using a for Loop to Reverse a String



<HTML>
<BODY>
<H1>
<SCRIPT
      var newString = ""
      var theString = "This is a test"
      var counter = theString.length; 

      for (counter  ;counter > ;counter -- ) { 
         newString += theString.substring(counter-1, counter)
      
      document.write(theString + " reversed is " + newString + "!")
   </SCRIPT>
</H1>
</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