Can someone explain to me why this is wrong:
// Example
function ourTrueOrFalse(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}
// Setup
function trueOrFalse(wasThatTrue) {
// Only change code below this line.
if (true) {
return "Yes, that was true";
}
return "No, that was false";
}
// Only change code above this line.
// Change this value to test
trueOrFalse(false);
And this is right:
// Example
function ourTrueOrFalse(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}
// Setup
function trueOrFalse(wasThatTrue) {
// Only change code below this line.
if (wasThatTrue) {
return "Yes, that was true";
}
return "No, that was false";
}
// Only change code above this line.
// Change this value to test
trueOrFalse(false);
I’m not sure if I’m thinking correctly. I might just be tired or not understanding the flow of execution, but from what I see with the correct code, the function trueOrFalse(wasThatTrue)
sets itself up to only accept the answer of isItTrue, or something. So how does trueOrFalse(false) change the output at all?
I think I’m missing something and am not thinking straight on top of that? It’s not like it’s hard to understand, either. I use if
statements all the time in this game I play, but it seems so confusing here.
Though when I use if
statements, it usually is in the form of if(item == null)
or if(item != null)
.