If / Else
Conditional branching with if and else.
Syntax
if (condition) {
// runs when condition is true
}
If / Else
if (score >= 90) {
Print("Grade: A");
} else {
Print("Grade: B or lower");
}
Else If Chain
if (score >= 90) {
Print("A");
} else if (score >= 80) {
Print("B");
} else if (score >= 70) {
Print("C");
} else {
Print("F");
}
With Boolean Variables
active is true;
if (active) {
Print("System active");
}
Comparison Operators
if (x == 10) { }
if (x != 0) { }
if (x > y && x < z) { }
if (a || b) { }