String.prototype.toWellFormedintermediate'hello'.toWellFormed() // β 'hello'
'π'.toWellFormed() // β 'π'
'οΏ½'.toWellFormed() // β 'οΏ½'Use toWellFormed() to replace lone surrogate code units with the Unicode replacement character U+FFFD (ES2024).
Emoji characters use surrogate pairs correctly. A well-formed emoji string is returned unchanged.
Challenge: Implement wellFormedEmoji() that shows an emoji string is unchanged.
wellFormedEmoji() // β 'π'