Basic JavaScript - Use Conditional Logic with If Statements

Tell us what’s happening:
Describe your issue in detail here.
It says the trueOrFalse function when false should return the string “No, that was false”

What am I doing wrong.

   **Your code so far**
function trueOrFalse(wasThatTrue) {
 // Only change code below this line
if (trueOrFalse){
 return "Yes, that was true";
return "No, that was false";


 // Only change code above this line

   **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Use Conditional Logic with If Statements

Link to the challenge:

What’s the condition that you’re checking inside your if statement?

Its checking if the function trueOrFalse is true, then returning “Yes, that was true” when true.
If false its returning “No, that was false”

The problem is saying when false its not returning the string “No, that was false” despite there not being an obvious problem. Can you help me out?

There is an ‘obvious’ problem if you try to call your function.

Add a function call.

Wait… There is a function call… What is the console telling you? You should see an error message about an undefined variable.

You need to change if (trueOrFalse){ to if (wasThatTrue){ otherwise you will never check if the argument is true or false

// running tests


should return the string

No, that was false

// tests completed

You could do the debugging for him… Or you could tell him where to find the error message and how to interpret it so he can know how to fix similar problems in the future…

I mistook the function for the argument, thank you.

1 Like


I’d start to figure this out by trying to run the code and console.loging the output.

From there I’d this condition to see why it is always returning the ‘Yes…’

The console will tell you that the thing in the condition is [Function: trueOrFalse], which leads to the issue

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.