Use Conditional Logic with If Statements. What am I doing wrong?

Use Conditional Logic with If Statements. What am I doing wrong?
0.0 0

#1

Tell us what’s happening:
I can’t tell what I’m doing wrong here. Please, someone, help.

Your code so far


// 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);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/use-conditional-logic-with-if-statements


#2

You are not using the whatThatTrue parameter to test if it is true or not in the if condition. If you usetrue as a condition it will allways enter that branch of the if/else block, because true will evaluate allways as true.


#3

The above will always evaluate to true, no matter what you pass into the function. You need to compare the argument named wasThatTrue to the value true instead.


#4

ok wrote it as if(wasThatTrue == true){
return ‘yada’
}

and it worked. Is that the only way to do it though?


#5

You can also write it as if(wasThatTrue) {
You will learn in a later lesson why.


#6

right after I sent the reply I realized that . I understand why. Thank you!