JS Built-ins
StringString.prototype.isWellFormedintermediate

String.prototype.isWellFormed() β€” lone surrogate is false

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

A string containing a lone high surrogate (\uD800) is not well-formed.

Challenge: Implement hasLoneSurrogate() that returns true when the string '\uD800' is NOT well-formed.

hasLoneSurrogate() // β†’ true  (it is NOT well-formed)
πŸ’‘ Hints (1)
  • β€’ A lone surrogate (without its pair) makes a string not well-formed.