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 trialMatt Leblanc
2,100 PointsIf "l" comes before "z" how is "lion" not greater than "zebra"?
the question is asking ('lion' < 'zebra') In which case l comes before z. Thus, it should be greater than zebra. Unless I'm misinterpreting it, than this might be an error.
3 Answers
Jennifer Nordell
Treehouse TeacherHi there, Matt Leblanc! While james south has provided a really solid answer, let me see if I can put it a little differently. When you hit a key on your keyboard, your computer doesn't see a letter. Your computer doesn't even know what a letter is really. It sees a number. These numbers are determined by the character encoding system you're working with. In every system I'm aware of, there is generally a 26 letter block laid out with consecutive numbers that begin with "a" and end with "z". Also, there will be another 26 letter block that begins with "A" and ends with "Z".
As a child, you may have developed a "code" with your friends which substituted letters for numbers. Something like a = 1, b = 2, c = 3, d =4 ...
. This is exactly the same principle. The letters that come first in the alphabet have a lower numerical value.
Take a look at this ASCII chart and take a look specifically at the numbers 65-90 and 97 to 122.
Hope this helps!
james south
Front End Web Development Techdegree Graduate 33,271 Pointsl comes before z the same way 3 comes before 7. so letters earlier in the alphabet are less than subsequent letters.
1 < 2
true
'l' < 'z'
true
'zebra' > 'lion'
true
'zebra' < 'lion'
false
Matt Leblanc
2,100 PointsOH. That makes sense. Phew. I automatically assumed the a or A would be greater just because it starts the alphabet. Now that I know a = 1, b = 2....etc. That is why l = 12 is less than z = 26. Or how the computer sees it as 12 < 26 Thanks for the comments!