Reverse a string
Easy
10
76.7% Acceptance
You have been asked to write a function reverseAString(str)
that takes in a string str
as an argument. The function should return a new string that is the reverse of the input string.
Instructions
- If the input string is empty, then return an empty string.
- The output should always be the argument string in reverse order.
Example test cases
reverseAString("hello") // Output: "olleh" reverseAString("hi") // Output: "ih" reverseAString("gfedcba") // Output: "abcdefg"
Hints
- You can chain multiple built-in methods.
- Strings are immutable, so return a new string.