Sequence NODE_141
EasyReverse a String
JavaScript
Technical Specification
Given a string, return a new string with the characters in reverse order.
Input/Output Samples
Input:"hello"
Output:"olleh"
Input:"happy"
Output:"yppah"
Optimal Logic Path
function reverseString(str) {
return str.split("").reverse().join("");
}Architectural Deep-Dive
We split the string into an array of characters, reverse the array using the built-in method, and then join it back into a string.