Normally I would just use something like str[i]
.
But what if str = "☀️"
?
str[i]
fails. for (x of str) console.log(x)
also fails. It prints out a total of 4 characters, even though there are clearly only 2 emoji in the string.
What's the best way to iterate over every character I can see in a string (and newlines, I guess), and nothing else?
The ideal solution would return an array of 2 characters: the 2 emoji, and nothing else. The claimed duplicate, and a bunch of other solutions I've found, don't fit this criteria.