For this challenge, you will be given a string of text and valid parentheses as input. Write a function that will return the string with the text inside parentheses reversed. If there are nested parentheses, then that too must be reversed. This pattern should repeat for however many layers of parentheses there are.
reverseInParens("h(el)lo") == "h(le)lo");
reverseInParens("a ((d e) c b)") == "a (b c (d e))");
reverseInParens("one (ruof ((rht)ee) owt)")
reverseInParens("one (two (three) four)")
Good luck and have fun!
Want to propose a challenge idea for a future post? Email email@example.com with your suggestions!