LearnFrenzy
Sign in Take a free test

Strings · Find the Error · Question 10

Error: an unknown normalisation form Answer, explanation & discussion

  • Find the error
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

The code below stops with an uncaught error. Which statement correctly describes the problem?

main.js
const name = "Ame\u0301lie";          // e + combining accent
console.log(name.normalize("NFC").length);
console.log(name.normalize("UTF8").length);
  • A It prints 7 and 7
  • B It prints 6, then RangeError: "UTF8" is not one of NFC, NFD, NFKC or NFKD Correct
  • C It prints 6 and 6
  • D SyntaxError
Correct Answer: Option B

NFC combines e + accent into é (6 characters instead of 7). normalize accepts only the four Unicode forms; anything else throws a RangeError.

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