JS Built-ins
StringString.prototype.isWellFormedintermediate

String.prototype.isWellFormed() β€” normal 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()

str.isWellFormed() returns true if the string contains no lone surrogate code units (i.e., it is a valid Unicode string).

This is an ES2024 method.

Challenge: Implement checkWellFormed(str) that returns str.isWellFormed().

checkWellFormed('hello') // β†’ true
πŸ’‘ Hints (1)
  • β€’ Normal strings that do not contain lone surrogates are always well-formed.