what is if else condition and example? or
if else with example.
if else condition in Javascript
Javascript me if else condition me agar if block me di gayi condition true hoti h to if block ka statement exicute hoga otherwise condition false hoti hai to else block ka statement exicute hoga.
syntax:
if(condition) {
statement ;
}
Example 1:
//if else condition in javascript
let a = 5;
if(a<10) {
console.log("condition is true");
}
else
{
console.log("condition is false");
}
Output :
condition is true.
Example 2:
let a = 20;
let b = 10;
if(a > b)
{
console.log(" a is greater than b");
}
else {
console.log("b is greater than a");
}
Output :
a is greater than b.
Comments
Post a Comment