Created
September 1, 2016 04:07
-
-
Save jordancalder/6b186725866e3bedc27bb5ff933eb3bb to your computer and use it in GitHub Desktop.
CareerBuilder - Question 1 (String Reversal)
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
/* | |
Given a string, write a function or method that takes in that string, and returns the same string in reverse order. | |
· Example: Given the string “Hello”, your program would return “olleH” | |
· Do not assume that “Hello” is the only string it will handle | |
Please code without using framework string reversal | |
*/ | |
const stringReversal = (s) => s.split('').reverse().join(''); | |
const recursiveStringReversal = (s) => s === '' ? '' : recursiveStringReversal(s.substring(1)) + s[0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment