I can’t figure out why this doesn’t work, thanks for any help.
Your code so far
function trueOrFalse(wasThatTrue) {
// Only change code below this line
console.log(wasThatTrue)
if (wasThatTrue = true) {
return "Yes, that was true";
}
if (wasThatTrue = false) {
return "No, that was false";
}
// Only change code above this line
}
var pig = trueOrFalse (false);
console.log (pig);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:75.0) Gecko/20100101 Firefox/75.0.
Challenge: Use Conditional Logic with If Statements
Thanks for your replies but it didn’t help me.
Line 3 prints to the console that the variable wasThatTrue = false
but the function still evaluates wasThatTrue as being equal to true.
I just can’t see why.
Anybody?
You have met = assignment operator, and === is the comparison operator
They do different things
But this challenge was just teaching you that if you put the true boolean inside the parenthesis the if statement will execute, and if you put the false boolean, it will not execute
if you assign something to a variable you are overwriting a variable
look at the example code. It is that simple. You just needed to do the same thing with stuff named in a different way.