Conditionals & Logic

JavaScript Fundamentals13 pts

Back

Making Decisions with if/else

Conditionals let your code make decisions. The if statement runs code only when a condition is true. Add else for alternative code paths.

The ternary operator (condition ? valueIfTrue : valueIfFalse) is a compact way to write simple if/else statements.

Output:
  • Create function isEven
  • isEven(4) should be true
  • isEven(7) should be false
  • 0 is even
What does (5 > 3 && 2 < 4) evaluate to?
Select an answer
The && operator returns true only if BOTH conditions are true. The || operator returns true if EITHER condition is true.