Discussion: How Long Is a Pirate Flag?
Execute the code to understand the output and gain insights into how emojis are displayed as connected sequences and how their length is calculated in JavaScript.
We'll cover the following...
Verifying the output
Now, it’s time to execute the code and observe the output.
Press + to interact
// Happy Flag Day!const flag = "🏴☠";console.log(flag.length);
Understanding the output
You might have anticipated that the output would be 1
, but this code will actually output:
4
Emoji zero-width joiner (ZWJ)
The length of emojis may not be what ...