Created
January 4, 2023 22:16
-
-
Save sondr3/226590de44c5ee62fe2bed1d8018d2a6 to your computer and use it in GitHub Desktop.
Recursive reverse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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