Learn JavaScript
Conditionals
11.1
Lesson

if statement

We can use the if statement to execute a block of code when the given condition is true.

In the example given below, the given condition evaluates to true, so the code inside the block executes.

In the example given below, the given condition evaluates to false, and so the code inside the block does not execute. Therefore, there is no message in the output.