String.prototype.toWellFormedintermediate'hello'.toWellFormed() // β 'hello'
'π'.toWellFormed() // β 'π'
'οΏ½'.toWellFormed() // β 'οΏ½'Use toWellFormed() to replace lone surrogate code units with the Unicode replacement character U+FFFD (ES2024).
A lone high surrogate like '\uD800' is not a valid Unicode scalar. .toWellFormed() replaces it with '\uFFFD'.
Challenge: Implement fixLoneSurrogate() that converts '\uD800' to a well-formed string.
fixLoneSurrogate() // β 'οΏ½'