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 (Retired) Making Decisions with Conditional Statements Comparison Operators

comparison operator strings. true or false ? A < a ? which one?

Is the following condition true or false? ( 'lion' > 'zebra' ) the answer is False.

because When comparing strings, the first letter of the first string is compared to the first letter of the second string. Since 'l' comes before 'z' in the alphabet, 'lion' is not greater than 'zebra.'

Does JavaScript following the ASCII table in the order? if A < a is true because the lower case "a" is greater number than the capital "A" letter. my assume is true.

it was no teacher notes for students.

http://www.asciitable.com/

Please let me know thanks.

2 Answers

Joseph Casey
Joseph Casey
6,782 Points

It definitely follows the ASCII table for determining the highest value. Simply use this script below on something like JSFiddle to test it our yourself

var a = "z";
var b = "†";

if ( a > b ) {
alert("a is greater than b");
}
else if ( a === b ) {
alert("a equals b");
}
else if( a < b ) {
alert("a is less than b");
}
Kelly von Borstel
Kelly von Borstel
28,880 Points

Yes, it follows ASCII table, so you are correct.