/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var stringOri = "string"; var stringLen = stringOri.length; var reverse = ''; var x = 0; while(x < stringLen+1){ reverse += stringOri.substr(stringLen-x,1); x++; } document.write(reverse); // vai retornar "gnirts"