Introduction to JS
Introduction Of Javascript
These If-else statements are basically used to execute the code whether the condition is true or false. And in Js we have three types of If-else statement, these are as follows :-
Js If statement
It only execute the code or content when the particular condition is true.
Syntax
if(expression){
//content to be evaluated
}
Let's understand this by the following example:-
value of a is greater than 10
The condition is true so it gives the right output.
Js If-else statement
It execute the code or content in both case whether the particular condition is true or not.
Syntax
if(expression){
//content to be evaluated if condition is true
}
else{
//content to be evaluated if condition is false
}
Let's understand this by the following example:-
divisible by 5
The condition is true so it gives the right output or if the condition is false too than also it gives the output..
Js if...else if statement
If we are having possibility of many true conditions than we can use this statement.
Syntax
if(expression1){Let's understand this by the following example:-
a is equal to 20
Here we are having many possibility of many true conditions, our number can fall in any criterion. So in these type of situation we use this if... else if statement.
JS training insitute | Best IT Training classes in Gurgaon | Web Designing Training Institute