How can I use Function and JavaScript to reverse string?

Hello, I just started using n8n and don’t know JavaScript, but I needed to reverse a string that I get from JSON when I request via HTTP Request.

This is what the line I need looks like:

4U3Mt5CdzVmZp5WYtpzcshmO0AXbuAjNz8CNwMDMyAjMyAjM6YmN3QmN4MTOhVjY1MTYmR2MwYWO1YmZyYGZxkTYlZTNvUWY0cjY3MWY3ATYi1iNkNWYtIjZ3QTL3IWYk1iN4QTMlVWN48yckF2bsBXdyV2c19SbvNmLldWYy9Gdz1yapR2br5CZ19Gbj9yL

This string is encoded in Base64 and reversed. I solved the problem of decoding the string, but I can’t reverse it.
As a result, you should get a line like this:

Ly9jbG91ZC5rb2Rpay1zdG9yYWdlLmNvbS91c2VydXBsb2Fkcy84NWVlMTQ4Ni1kYWI3LTQ3ZjItYWNkNi1iYTA3YWM3Yjc0YWUvNTZlYTkxZGYyZmY1OWYwM2RmYTM1YjVhOTM4NmQ3NmY6MjAyMjAyMDMwNC8zNjAubXA0OmhsczptYW5pZmVzdC5tM3U4

So please help me solve this problem.
I don’t understand how to adapt the javascript code to work in n8n.
If you can explain your solution to this problem in detail, I would be very grateful.

1 Like

Hi @Igor_Makarov

Welcome to n8n community :tada:

Here is the example workflow for your usecase.

2 Likes

It’s beautiful!
I didn’t expect to get help so quickly.
Thank you, it works just the way I need it to.

2 Likes

Glad it helps :smile:
Enjoy :tada: