JS Built-ins
StringString.fromCodePointintermediate

String.fromCodePoint() β€” emoji / supplementary planes

πŸ“– Usage Example
String.fromCodePoint(65)       // β†’ 'A'
String.fromCodePoint(9731)     // β†’ 'β˜ƒ'
String.fromCodePoint(128512)   // β†’ 'πŸ˜€'

Use String.fromCodePoint() to create a string from Unicode code point values, including characters outside the BMP.

String.fromCodePoint() β€” Supplementary Characters

Code points above U+FFFF (like emoji) require two UTF-16 code units (a surrogate pair). String.fromCodePoint handles this automatically.

Challenge: Implement getEmoji() that returns the grinning face emoji 'πŸ˜€' using code point 128512.

getEmoji() // β†’ 'πŸ˜€'
πŸ’‘ Hints (2)
  • β€’ Emoji like πŸ˜€ have code points > 65535 and are represented as surrogate pairs in UTF-16.
  • β€’ `String.fromCodePoint(128512)` automatically generates the correct surrogate pair.