1function reverse(str){
2 let reversed = "";
3 for (var i = str.length - 1; i >= 0; i--){
4 reversed += str[i];
5 }
6 return reversed;
7}
1// New For loop available after ES2015
2function reverse(str){
3 let reversed = '';
4 for (let character of str){
5 reversed = character + reversed;
6 }
7 return reversed;
8}