Skip to content

Instantly share code, notes, and snippets.

@gogvale
Created June 21, 2020 03:19
Show Gist options
  • Save gogvale/8cd87730342f4c8c1e984ab30de6771d to your computer and use it in GitHub Desktop.
Save gogvale/8cd87730342f4c8c1e984ab30de6771d to your computer and use it in GitHub Desktop.
Recursive function to reverse string in javascript
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