Use Do while loop to reverse a string : while « Statement « JavaScript Tutorial






<HTML>
   <BODY>
   <H1>
   <SCRIPT>
      var newString = "";
      var theString = 'abcde';
      var counter = theString.length;
      do
      {
         newString += theString.substring(counter-1, counter);
         counter--;
      }
      while (counter > 0 );
      document.write(theString + " reversed is " + newString + "!");
   </SCRIPT>
   </H1>
   </BODY>
</HTML>








3.6.while
3.6.1.while loop
3.6.2.Use integer variable to control the while loop
3.6.3.Check the loop counter for while loop
3.6.4.Use while loop to output all elements in an array
3.6.5.Use Do while loop to reverse a string
3.6.6.Nesting If statement to a while statement
3.6.7.Using While loop to check user input