CodeClip

Challenge Description

Welcome to the coding challenge! Your task is to implement a function that reverses a given string. Consider edge cases such as empty strings or strings with special characters.

Requirements:

  • The function should accept one argument: a string.
  • It should return the reversed string.
  • The solution must be efficient (e.g., O(n) time complexity).

Example:


function reverseString(str) {
  // Your code here
}

// Example usage:
// reverseString("hello") should return "olleh"
                

Good luck! If you encounter any issues, refer to the documentation or seek hints.

Code Editor


function reverseString(str) {
// Your code here
return str.split('').reverse().join('');
}
            

Output / Test Results

Click "Run Code" to see output here.


// Example Test Case:
// Input: "hello"
// Expected Output: "olleh"
// Actual Output: (will appear here)

// Test Case 2:
// Input: ""
// Expected Output: ""
// Actual Output: (will appear here)