Conditional

A conditional is a statement that runs code only if a condition is true. It lets a program make decisions, most often using if, else if, and else.

General Programming

Syntax

if (condition) { ... } else { ... }

Examples

Python

temp = 30
if temp > 25:
    print("Hot")
else:
    print("Cool")

Output:

Hot

JavaScript

let temp = 30;
if (temp > 25) {
  console.log("Hot");
} else {
  console.log("Cool");
}

Output:

Hot

See also

Back to the Dictionary