Skip to content

Instantly share code, notes, and snippets.

@geraldyeo
Created July 31, 2016 02:22
Show Gist options
  • Save geraldyeo/581cdeae3f2d806c805940a20768df6f to your computer and use it in GitHub Desktop.
Save geraldyeo/581cdeae3f2d806c805940a20768df6f to your computer and use it in GitHub Desktop.
Reverse a string with recursion
function reverse(str) {
if (str === '')
return '';
else
return reverse(str.substr(1)) + str.charAt(0);
}
reverse("hello, world");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment