if Statement

Runs a block of code only when a condition is true.

What does if Statement do in JavaScript?

if Statement — Runs a block of code only when a condition is true.

if (stock > 0) {
    status = "Available";
} else {
    status = "Sold out";
}

Level: Novice · More JavaScript terms at this level

Updated

In other subjects