Using a Do/While Loop to Reverse a Text String : While : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » While »

 

Using a Do/While Loop to Reverse a Text String



<HTML>
<BODY>
<H1>
<SCRIPT
      var newString = ""
      var theString = "string"
      var counter = theString.length; 
      do 
      
        newString += theString.substring(counter-1, counter)
        counter--; 
      
      while (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
» While