JS Built-ins
StringString.prototype.isWellFormedintermediate

String.prototype.isWellFormed() β€” mixed surrogate string

πŸ“– Usage Example
'hello'.isWellFormed()      // β†’ true
'πŸ˜€'.isWellFormed()         // β†’ true
'οΏ½'.isWellFormed()     // β†’ false

Use isWellFormed() to check if a string contains no lone surrogate code units (ES2024).

String.prototype.isWellFormed() β€” Mixed Content

A string containing even one lone surrogate is not well-formed, regardless of other content.

Challenge: Implement mixedSurrogateWellFormed() that returns whether 'hello\uD800world' is well-formed.

mixedSurrogateWellFormed() // β†’ false
πŸ’‘ Hints (1)
  • β€’ A single lone surrogate anywhere in the string makes it not well-formed.