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 Introducing JavaScript Finishing the Game Control the Flow with Conditional Statements

The difference between =, ==, === in JavaScript?

https://teamtreehouse.com/library/control-the-flow-with-conditional-statements

I used == instead of === as what the video said and it did the same work

my question is: currect me if I am wrong = means placing the value on the right to the variable on the left of = sign === making sure that both sides are equivalent to each other what does == mean in JS?

1 Answer

The "=" will assign a value (so using 'x = 10' will the value of x 10), the "==" will check if the value is equal (so 10 == "10" will be true, 1 == true will be true and "5.2 == "5.3" will be false), the "===" will check if the value AND type are equal (so 10 == "10" will now be false as one is a number, 'true === 1' will be false as the are not exactly the same and the other is a string and 5 === 5 is true as they are both numbers), so basically if you more want more accuracy use the "===" operator.

Thank you so much. That was extremly helpful

No Problem :)