LearnFrenzy
Sign in Take a free test

Strings · JavaScript Strings MCQ · Question 6

Why is "a" < "B" false? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

Why is "a" < "B" false in JavaScript?

  • A Comparisons are always case-insensitive
  • B Single characters cannot be compared
  • C Because "a" is a vowel
  • D Strings are compared by UTF-16 code: "B" is 66 and "a" is 97, so all capitals sort before lower-case letters Correct
Correct Answer: Option D

The < operator compares code units. Use a.localeCompare(b) or compare lower-cased strings for human ordering.

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