Reverse a String in JavaScript
There are the common approaches to reverse a string in JavaScript. These are:
Table of Content
- Reverse a String in JavaScript
- Using reduce() and split() Methods
- Using split(), reverse() and join() Methods
- Using Spread Operator
- Using Array.form() and reverse() Methods
- Using Spread Operator and reduce() method
- Using for Loop
- Using substring() and a Decrementing Index
- Using Recursion
- Using Stack
Reverse a String in JavaScript
We have given an input string and the task is to reverse the input string in JavaScript. It is a very common question asked in a JavaScript interview. There are various methods to reverse a string in JavaScript, which are described below with examples.
Examples:
Input: str = "w3wiki"
Output: "skeeGrofskeeG"
Input: str = "Hello"
Output: "olleH"
Contact Us