Posted By

joaobarbosa on 12/04/10


Tagged

String manipulacao


Versions (?)

String de trás para frente


 / Published in: JavaScript
 

  1. var stringOri = "string";
  2. var stringLen = stringOri.length;
  3. var reverse = '';
  4. var x = 0;
  5.  
  6. while(x < stringLen+1){
  7. reverse += stringOri.substr(stringLen-x,1);
  8. x++;
  9. }
  10.  
  11. document.write(reverse); // vai retornar "gnirts"

Report this snippet  

You need to login to post a comment.