JS Built-ins
StringString.prototype.isWellFormedbeginner

String.prototype.isWellFormed() β€” empty string is true

πŸ“– 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() β€” Empty String

An empty string has no code units, so it cannot contain lone surrogates. It is well-formed.

Challenge: Implement emptyIsWellFormed() that returns ''.isWellFormed().

πŸ’‘ Hints (1)
  • β€’ An empty string trivially satisfies the well-formedness condition.