Method 1 :
console.log("before reverse " , s)
let result = s.split(''); //convert string to array
let result1 = result.reverse(); // reverse the array
let result2 = result1.join('') // convert the reversed array back to string
console.log("after reverse " ,result2)
}
reverseString("12345");
ref: https://www.freecodecamp.org/news/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb/
0 Comments