Created
June 21, 2020 03:19
-
-
Save gogvale/8cd87730342f4c8c1e984ab30de6771d to your computer and use it in GitHub Desktop.
Recursive function to reverse string in javascript
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
function reverseString(string){ | |
if(string==="") return ""; | |
sliced = string.slice(0,-1); | |
return string[string.length-1]+reverseString(sliced); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment