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 
   
    charles bempah
1,295 PointsConfusion over the equals operator. Please help me understand
Here is my workspace: https://w.trhou.se/bj2a5e48ox
Just wanted some clarification over differences with the '=', '==' and '===' operator and how it relates to the code above. Ran into some problems with it and it turned out i was using the wrong amount of equal operators. I'd like to know better when I would use what (amount of) equal operators.
Also I was wondering if someone could explain why with in the last 'if' operator I didn't need to use a '=' or '==' or '===' for '( correctGuess )' to equate it with true (or false)
2 Answers
 
    Jorge Lopez
Python Development Techdegree Graduate 35,350 PointsOk, so for the difference between the number of '=' operators, one '=' operator is a setter. So notice how on the first 3 lines of your script you're using one '=' when declaring the variables? That's because you're DECLARING "This is going to be a placeholder for that". Now for the multiples, 2 and 3 '=' operators are checkers. When you use '==' (you don't have any in this script) you're asking your script to check if both those values are equal. You are ASKING "Is this the same value as that?" and you're ONLY checking the value. What I mean by that is that you can have 4 as an integer and '4' as a string and according to the double '==' this is true. The triple, which you're using in your script, is a strict comparison. What that means is that the value AND the type have to be the same, so integer 4 and string '4' will NOT evaluate to true. For that to evaluate to true you would need both values to be 4 AND both types to be an integer, or both types to be a 'string'.
On to your second question. When using a conditional(if) statement, what you're putting in the parentheses has to evaluate to TRUE in order for that block of code to run, and if it's FALSE then it won't run that code and move on to your ELSE or ELSE IF if you've written one. In line one of your code you declared your variable 'correctGuess' to be FALSE by default, but then you wrote a few different conditions for how 'correctGuess' could evaluate to true, so with the last conditional if (correctGuess) it's just saying "If 'correctGuess' is TRUE, then run this block of code or ELSE run this other block'. It'd be the same as writing if (correctGuess === true) { code block };
If I confused you anywhere let me know and I'll elaborate on it. So ask away if its true that you're confused.
if (confused) {
   askAway();
}
Moderator Edit: Moved reply from Comments to Answers
 
    charles bempah
1,295 PointsYes that all completely makes sense. Thanks so much.