DEV Community

Cover image for Day 5 of JavaScriptmas - Reverse String Solution
Sekti Wicaksono
Sekti Wicaksono

Posted on

Day 5 of JavaScriptmas - Reverse String Solution

Day 5 is Reverse string. The classic problem to reverse string.

For instance string 'Hello' reversed into 'olleH'.
Since a string can be split into array, we can reverse the arrangement of array with reverse and concat the array with join to reverse it back into single string.

There is JavaScript solution

function reverseAString(str) {
    return str.split('').reverse().join('');
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)