How to reverse string using Javascript also how to assign it in output
Hello.
Everyone here is giving the exact same answer. Turns string into array and reverse the array.
But because of encoding, some characters take a combination of two characters. Like emojis or non-ASCII languages.
TLDR: split.reverse.join works for "Hello World", but fails for "👋🌍". You most never reverse the order of those or they turn into unreadable �� � � .
This is a mission for Intl.Segmenter, a JavaScript API for language-sensitive text segmentation. It breaks text into meaningful units like graphemes*, words, or sentences.
OS supports this so you can just use the following code in your JS widget:
const segmenter = new Intl.Segmenter("en", { granularity: "grapheme" });$parameters.out = [...segmenter.segment($parameters.in)].map(segment => segment.segment).reverse().join("");
* A grapheme is the smallest unit of a writing system that represents a meaningful character to the reader.
Hi @Shivani More,You can refer to the below js.Here,
Thanks
Hi,
Thanks for help
Hi Shivani,
you can use the below JS to reverse the string
$parameters.ReversedString = $parameters.String.split('').reverse().join('');
hope it helps.
Please check the link below
https://www.outsystems.com/forums/discussion/71296/how-can-i-reverse-text/
there are lots way to reverse the string in javascript
Reverse a String With Built-In Functions
function reverseString(str) { return str.split("").reverse().join("");}reverseString("hello");
Reverse a String With Recursion
function reverseString(str) { return (str === '') ? '' : reverseString(str.substr(1)) + str.charAt(0);}reverseString("hello");
easiest way is Reverse a String With Built-In Functions
https://personal-u1aragiz.outsystemscloud.com/FileViewerDemo/Reverse
Hi Shivani,Please refer this Discussion https://www.outsystems.com/forums/discussion/71296/how-can-i-reverse-text/
Hi,Please find the attached oml, and demoThanks,sahana
Hi @Shivani More ,
Refer this OML,
Thanks,
Sudha Narayanan
I notice you have marked every single reply as solution.
It is possible that sometimes more than 1 reply have the correct solution and have a similar quality, so that can happen, but EVERY reply, means that the value of the solution stamp is gone, a future reader can't use this to quickly scan the replies.
In light of the explanation by @Nuno Reis , that one seems to be the more complete, and less fragile one, so I would like to suggest that you unmark all the others.
Dorine
Below I have given you a javascript function which will reverse the String
function reverseString(str) { return str.split("").reverse().join(""); }
let input = "Hello, World!";let output = reverseString(input);