Posted By

alvincrespo on 02/17/10


Tagged

javascript js String loop reverse for


Versions (?)

Javascript - Reverse a String


 / Published in: JavaScript
 

Just a simple snippet on how to reverse a string using a for loop.

  1. var aString = "Hotel";
  2. var rString = "";
  3. for(var i = aString.length; i>=0; i--){
  4. rString += aString.substr(i,1);
  5. }

Report this snippet  

You need to login to post a comment.