← All Exercises

String Reversal

basicjavascript~10min

Background

String reversal is a common interview question and a building block for palindrome checks and text processing.

Problem

Write a function that takes a string as input and returns a new string with all characters in reverse order.

Input

A string of zero or more characters.

Output

A new string with characters in reversed order.

Sample tests

Sample 1

Input: "hello"
Expected: "olleh"

Your solution

Learning objective

Understand string immutability and chaining array methods for transformations.