Skip to content

Instantly share code, notes, and snippets.

@sondr3
Created January 4, 2023 22:16
Show Gist options
  • Save sondr3/226590de44c5ee62fe2bed1d8018d2a6 to your computer and use it in GitHub Desktop.
Save sondr3/226590de44c5ee62fe2bed1d8018d2a6 to your computer and use it in GitHub Desktop.
Recursive reverse
const reverseString = (input) => {
return (input === "") ? "" : reverseString(input.substring(1)) + input.charAt(0);
}
console.log(reverseString("hello"));
console.log(reverseString("world"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment