Conditional statements
| if...else | |
| switch | |
| Ternary operator |
if...else
The if...else statement executes a block of code if a specified condition is true.
if (x > 0) { console.log("positive"); } else { console.log("non-positive"); }
let result = x > 0 ? "positive" : "non-positive";
Next: Loops and iteration
Article author: Arthur Isaev