Image Image Image Image Image
Scroll to Top

To Top

JavaScript

20

Apr
2018

No Comments

In JavaScript

By Manny

Reverse a string algorithm with JavaScript

On 20, Apr 2018 | No Comments | In JavaScript | By Manny

Ever wondered how many different ways you can write a reverse string algorithm in JavaScript?

You can use a combination of helper methods built into JavaScript:

split(”);
The split method separates the string into substrings, which are separated by a given separator. The separator can be a blank space, comma or whatever you need.

reverse();
The reverse method changes the order of the element in the array in situ at call time. The zeroeth element will become the last element in the array and the last element the first in the array.

join(”);
The join method will recombine all the given items in the array and then return the array.

Tags |