Basic JavaScript - Use 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 (wasThatTrue){
  return"yes, that was true";

return"no, that was false";
console.log(trueOrFalse(true);)
}

  // 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/106.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Use Conditional Logic with If Statements

Link to the challenge:

Hey!

The problem with your code is that you’re trying to run your logic after using the return statement.

image

This is the reason your code after the return statement is dimmed out.

Whenever you use the return statement in your code, any code you write after that doesn’t run. If you run the same code in a text editor, this is the error you would get.

Hope this helps! :smile:

  1. You didn’t close the if statement correctly. Either remove the opening bracket { or remember to close } the statement.

These all work the same (with a single expression after the if statement)

if (condition) return "some value";

if (condition)
  return "some value";

if (condition) {
  return "some value";
}
  1. You are not returning the correct string values. Check the requirement.

  2. You can not have a semicolon after a function call inside the log method

console.log(someFn()); // works
console.log(someFn();); // syntax error