Skip to content

Instantly share code, notes, and snippets.

Created July 31, 2016 19:47
Show Gist options
  • Save anonymous/2dc37ec6c7fe32447ed249e6681a03be to your computer and use it in GitHub Desktop.
Save anonymous/2dc37ec6c7fe32447ed249e6681a03be to your computer and use it in GitHub Desktop.
https://repl.it/CU9g/231 created by sethopia
/*
REVERSE STRING
Create a function that takes a string of any length as input and returns that string reversed.
Use recursion ;)
*/
function reverseString(str){
var n = str.length-1;
if(str.length < 1) return str;
return str.charAt(n) + reverseString(str.slice(0,n))
}
console.log(reverseString("Hello"));
Native Browser JavaScript
>>> olleH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment