Skip to content

Latest commit

 

History

History

13

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Reverse a string

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.