Created
July 31, 2016 19:47
-
-
Save anonymous/2dc37ec6c7fe32447ed249e6681a03be to your computer and use it in GitHub Desktop.
https://repl.it/CU9g/231 created by sethopia
This file contains 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
/* | |
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")); |
This file contains 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
Native Browser JavaScript | |
>>> olleH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment