Skip to content

Instantly share code, notes, and snippets.

@jordancalder
Created September 1, 2016 04:07
Show Gist options
  • Save jordancalder/6b186725866e3bedc27bb5ff933eb3bb to your computer and use it in GitHub Desktop.
Save jordancalder/6b186725866e3bedc27bb5ff933eb3bb to your computer and use it in GitHub Desktop.
CareerBuilder - Question 1 (String Reversal)
/*
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