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 trial

JavaScript JavaScript Basics Making Decisions in Your Code with Conditional Statements Conditional Statements and Operators Review

lion comes before zebra

How does ('lion' > 'zebra') true when "l" comes before "z?" Shouldn't it be true/

3 Answers

Hi Alana!

( 'lion' > 'zebra' )

evaluates to false.

Quiz Question 4 of 7
Is the following condition true or false?

( 'lion' > 'zebra' )
 Well done! When comparing strings, the first letter of the first string is compared to the first letter of the second string.  
A   
True. Since 'l' comes before 'z' in the alphabet, 'lion' is greater than 'zebra.'

B   <--- I picked this answer and it passed
False. Since 'l' comes before 'z' in the alphabet, 'lion' is not greater than 'zebra.'

I hope that helps.

Stay safe and happy coding!

yes, that is what I am asking why is it false when "l" comes before"z." It should be true

Hi Alena!

In the computer world (and other places, too), 'z' is considered a higher character than 'a' (or 'l').

In a database, if you sorted a table of animals by the animal name in ascending (low to high/default) order, it will sort it from a-z.

If you sort in descending (high to low) order, it would sort z-a.

You can test it this way:

var animals = ["zebra", "aardvark", "lion"];
animals.sort(); // default sort is ascending (from low to high)
console.log(animals);

It should print out "Array(3)", which if you expand it, will give you:

0: "aardvark"
1: "lion"
2: "zebra"
length: 3
etc....

aardvark being the lowest value and zebra being the highest

I hope that helps.

Stay safe and happy coding!

Hi Peter,

I want to thank you for your help with the "if" "else" comparison. I had no idea to copy and past in the challege, but I did and it worked. Thanks again ... I'm so thankful.

Alana