7/9 == or ===?


#1

I completed this section just fine, but I was checking my code against the hint from part 7.

my code is

if(charactersLeft <= 0)
{$('.btn').addClass('disabled');}
else if (charactersLeft === 140)
{$('.btn').addClass('disabled');}
else{$('.btn').removeClass('disabled');}

the Hint code is the same except for the ===

if(charactersLeft <= 0)
{$('.btn').addClass('disabled');}
else if (charactersLeft == 140)
{$('.btn').addClass('disabled');}
else{$('.btn').removeClass('disabled');}

why is this? I ran it both ways and they both worked.

thanks for the explanation!


#2

== does type conversion. so if you're comparing a integer with a string, it will convert both to the integer.
=== compares the values despite their type.

for example:
7 == "7" // true - converts both to int
7 === "7" // false - sees one as int, other as string


#3

ok, makes sense!

Thank you @heykat