Conditional Statements

Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. In JavaScript we have the following conditional statements:

If Statement:

Use the if statement to execute some code only if a specified condition is true. Syntax
if (condition)
{

code to be executed if condition is true
}