Hi, I’m new and don’t seem to be able to reply directly in the challenge topic:
I have two questions. One is that I’m wondering why I can pass arguments other than true or false and still pass the challenge. For instance, I can pass a string:
trueOrFalse("h");
and it will evaluate as true and I pass the challenge.
Or I can pass a number greater than zero; it will evaluate as true and I pass the challenge.
Or I can pass a zero; it will evaluate as false and I pass the challenge.
Why?
My other questions is about if statements in general. Is it the case that everything else inside a function will only run if the if statement evaluates as false? This isn’t explicitly stated in the challenge but seems to be the case.
In general I’m finding the challenges rather sparse on explanation.
Here is the full code that is currently passing the challenge:
// 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("h");