string reverse in javascript using for loop code example
Example 1: reverse string js
str.split('').reduce((reversed, character) =>{
return character + reversed;
}, '');
//apple = leppa
Example 2: how to reverse a string in javascript without using reverse method
function reverseString(str) {
if (str === "")
return "";
else
return reverseString(str.substr(1)) + str.charAt(0);
}
reverseString("hello");