Examples
Write reverse so that the following cases hold.
- Input
reverse("hello")Output"olleh" - Input
reverse("FrontendPro")Output"orPdnletnorF"
Answer
Reverse the string with split, reverse, and join:
function reverse(str) {
return str.split("").reverse().join("");
}
