Quantcast
Channel: How to reverse a string that contains complicated emojis? - Stack Overflow
Viewing all articles
Browse latest Browse all 11

How to reverse a string that contains complicated emojis?

$
0
0

Input:

Hello world👩‍🦰👩‍👩‍👦‍👦

Desired Output:

👩‍👩‍👦‍👦👩‍🦰dlrow olleH

I tried several approaches but none gave me correct answer.

This failed miserablly:

const text = 'Hello world👩‍🦰👩‍👩‍👦‍👦';const reversed = text.split('').reverse().join('');console.log(reversed);

This kind of works, but it breaks 👩‍👩‍👦‍👦 into 4 different emojis:

const text = 'Hello world👩‍🦰👩‍👩‍👦‍👦';const reversed = [...text].reverse().join('');console.log(reversed);

I also tried every answer in this question, but none of them worked.

How can I get the desired output?


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images