Link Search Menu Expand Document

Use Conditional Logic with If Statements

Summary

  • If statements are used to make decisions in code.
  • The keyword if tells JavaScript to execute the code in the curly braces under certain conditions, defined in the parentheses.
  • These conditions are known as Boolean conditions and they may only be true or false.

Final Code

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

}