Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndy tran
7,112 PointsComparison of two strings
( 'lion' > 'zebra' ). Why is this condition false? I thought the first letter 'l' came before letter 'z' should be greater, so the string 'lion' should be greater than string 'zebra'.
1 Answer
Steven Parker
231,275 PointsSince "l" comes before "z" in the alphabet, "l" has a lower value than "z". So a word starting with "l" has a lower value than a word starting with "z".
So "lion" < "zebra" (and 'lion' > 'zebra' is false).
Andy tran
7,112 PointsAndy tran
7,112 PointsSo the first word with the first letter that comes before the first letter of the second word has lower value than the second word right. So, ''apple'' has a smaller value than '' bear' right cause letter 'a' in string 'apple' comes before letter 'b' in string 'bear'.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsYes, just like in numbers 1 comes before 3 so 1 is less than 3.