Help on comparisons string showing false?


#1

i'm having trouble with question 13 Comparisons, this is my string:
The first two are showing 'true', the third is showing false & true, I don't understand why as have '==='

console.log("Xiao Hui".length < 122);
console.log("Goody Donaldson".length < 8);
console.log(8*2 === 16);

many thanks


#2

Hey @codeplayer88578! Firstly just quickly organize your code by formatting it. You do that by selecting over your code and hitting CTRL + K. Secondly the problem is that if you want to check for equality you use 2 equal signs! Not 3. So

Your code:

Correct Code:
console.log(8*2 == 16);

Hope it helped! If it didnt please reply saying so!


#3

This is the one that is giving your false result.


#4

=== is a valid JavaScript comparison operator.

Unless you have a good reason to use ==, using === is safer.


#5

Oh, Why do i always confuse Java with JavaScript :frowning:


#6

Thank you, I've tried the 3rd question using '==' instead of '===' still seem to be getting same result true true false true. I'll have a look at this again hopefully can figure it out :smile:


#7

I think you missed this reply: http://discuss.codecademy.com/t/help-on-comparisons-string-showing-false/14467/3?u=albionsrefuge


#8

Thank you, changed the < to a >, all 'true' now :smile: