DEV Community

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

Posted on

1

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)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay