Question 10
Back to Exercise
Two strings both display as "José" but a === b is false. What is the likely cause and fix?
- A One string has a hidden space – use trim()
- B é is stored as one character in one string and as e + combining accent in the other – compare a.normalize() === b.normalize() Correct
- C They have different case – use toLowerCase()
- D Strings with accents cannot be compared
Correct Answer: Option B
Unicode allows composed and decomposed forms. normalize("NFC") (the default) converts both to the composed form, so equal text compares equal.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!