|
| |
JavaScript if else |
If else conditional statement is very common in JavaScript. This logical condition checking is done inside a script as per the requirement. Here is the syntax for if else condition in JavaScript.
If(condition){
Code;
}else{
Code;
}
The first block is executed if the condition is TRUE and second block inside the else condition is executed if the condition is FALSE.
Let us learn one practical example and you can see this in action at confirm window tutorial. Here is the code.
var my_string = confirm("Are you satisfied with the quality of the tutorials here?");
if(my_string){alert("Thank you");
}else{
alert("Please use the contact us page to give your feedbacks");}
| |
| Subscribe |
|
Submit your email address and receive
article and product notifications. Your email is safe with us.
|
|
|
|