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)

Join the Runner H "AI Agent Prompting" Challenge: $10,000 in Prizes for 20 Winners!

Runner H is the AI agent you can delegate all your boring and repetitive tasks to - an autonomous agent that can use any tools you give it and complete full tasks from a single prompt.

Check out the challenge

DEV is bringing live events to the community. Dismiss if you're not interested. ❤️