Beginner
Reverse a String
Description
Your task is to write a function that takes a string as input and returns the reversed version of that string.
This problem is a fundamental concept in programming with applications in:
- Text manipulation, such as formatting and processing user input.
- Algorithm challenges, like checking if a string is a palindrome.
- Data transformations, for example, reversing order in names or codes.
Requirements
Input: A valid non-empty string.
Output: A new string with characters in reverse order.
Considerations:
- The function should handle strings containing spaces, punctuation, and special characters.
- Strings with a single character should return the same string.
- Uppercase and lowercase letters should be handled correctly without modification.
- You do not need to handle non-string inputs.
Example Usage
reverseString("hello");// Expected output: "olleh"reverseString("TechBlitz");// Expected output: "ztilBhceT"reverseString("12345");// Expected output: "54321"reverseString("A B C");// Expected output: "C B A"
Did you know?
The first computer bug was a moth found in a Harvard Mark II computer.
Test Cases
Input:
"hello"
Expected Output:
"olleh"