DEV Community

Shariif
Shariif

Posted on

How To Reverse A String

This is amazing. The more I tinker, the better I pick a great understanding that makes up for all the troubles of reading, listening, writing and trying to make a sense of it all. Last night before I called in for the night, late as it was, I had an ahuuh experience of understanding about what I was actually doing. I was writing codes in JavaScript and I wasn't copying somebody else's tutorial or blog.

I am happy to say that I am satisfied. Alhamdulillah, and thanks to all involved. I am pushing forward and I won't stop till I get enough. And some more...!

Now this will reverse engineer whatever you write inside the input field and then saves it inside function update, and when you click on the button, you should be able to see it on the display field above what you wrote turned backward. A simple application, yet powerful capabilities.

Thanks for reading and have fun coding...!

Top comments (4)

Collapse
 
frankwisniewski profile image
Frank Wisniewski

seen 1000 times and wrong 1000 times...

const str = 'Hello 😊 World';
const reversedStr = str.split('').reverse().join('');
console.log(reversedStr); // 'dlroW �� olleH'
Enter fullscreen mode Exit fullscreen mode
Collapse
 
djeylani profile image
Shariif

What do you mean? Please elaborate

Collapse
 
frankwisniewski profile image
Frank Wisniewski

Because that doesn't work in all cases. Use the intl.segmenter

developer.mozilla.org/en-US/docs/W...

Thread Thread
 
djeylani profile image
Shariif

Oh OK. Good to know. Thanks. Will learn more about it.