Back to questions
JuniorTheoryCommon
What does the program print?
console.log("10" < "9", 10 < 9);true false
- Expecting
"10" < "9"to compare numbers: two strings are compared character by character, and"1"comes before"9", so the result istrue. - Expecting numbers to be compared digit by digit too:
10 < 9compares two numbers by value, so it isfalse.
- How would you compare the strings
"10"and"9"as numbers? - What does
"Z" < "a"give, and why?