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!