LearnFrenzy
Sign in Take a free test

String Methods · Predict the Output · Question 16

Comparing composed and decomposed text Answer, explanation & discussion

  • Output
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 16 Back to Exercise

What does the following JavaScript code print (console output, as in Node.js)?

main.js
const composed = "é";       // é as one character
const decomposed = "é";    // e + combining acute accent
console.log(composed === decomposed, composed === decomposed.normalize(), decomposed.length);
  • A true true 1
  • B false false 2
  • C false true 1
  • D false true 2 Correct
Correct Answer: Option D

The two strings look the same but contain different code units. normalize() (NFC by default) composes e + accent into é.

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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links