JS Built-ins
StringString.prototype.normalizeintermediate

String.prototype.normalize() β€” NFC (default)

πŸ“– Usage Example
const e1 = 'Γ©'           // Γ© precomposed
const e2 = 'é'    // e + combining accent
e2.normalize('NFC') === e1    // β†’ true

Use normalize() to convert a string to a Unicode normal form, useful for comparing visually identical strings.

String.prototype.normalize()

str.normalize(form) returns the Unicode Normalization Form of the string.

  • NFC (default): Canonical Decomposition, followed by Canonical Composition (precomposed form).
  • '\u00e9' is the precomposed Γ© (NFC form).
  • '\u0065\u0301' is decomposed (e + combining accent, NFD form).

Challenge: Implement toNFC(str) using .normalize('NFC').

toNFC('\u0065\u0301') // β†’ '\u00e9'  (Γ© precomposed)
πŸ’‘ Hints (1)
  • β€’ `\u00e9` is precomposed Γ©. `\u0065\u0301` is e followed by a combining acute accent.