If
If anyone writing programs in JavaScript, conditional statements are very flexible and friendly. It enables you to control the flow of your programs using conditions, so you can make them more useful with few lines of more code. There are various types of conditional statements in JavaScript, including ‘if’ and ‘switch’ statements. If statements tell the computer to make decisions based on a condition the programmer specifies.
The syntax of a JavaScript if statement is:
if (condition == true)
{
//This block will be executed if 'condition' is true.
}
The syntax of a JavaScript if statement is:
if (condition == true)
{
//This block will be executed if 'condition' is true.
}