Usinggg Conditional Logic with If Statements

Tell us what’s happening:
Describe your issue in detail here.

  **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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36

Challenge: Use Conditional Logic with If Statements

Link to the challenge:

Please help my Function is not passing

Hello @Wale_native,

Your code cannot work because of your if condition. “trueOrFasle” isn’t a variable or anything in your code. What pass in the if statement should be evaluated. Look well the example in the course:

function test (myCondition) {
  if (myCondition) {
    return "It was true";
  }
  return "It was false";
}

test(true);
test(false);

Watch well the condition into the if statement. Here we pass an argument to the function test that we call myCondition. We test this argument and return something according to the fact it is true or not:

if (true) {
  return true;
} else {
  return false;
}

It is a good way to resume how work the if/else statement. Now compare with your code and how it should be:

if (trueOrFalse)  {
  return "Yes, that was true";
}
  
  return "No, that was false";

I told you that your if condition cannot work, but what about the else statement?

thank you so much i realised where my mistake was

if(wasThatTrue) {

return "Yes, that was true";

}

return “No, that was false”;

You’re welcome @Wale_native

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