JavaScript if else
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.
During execution of Script we frequently use if else condition checking. Here we will discuss few uses of it with code samples.
Checking numbersWe can check numbers by using if else condition. If numbers are less than fixed value then we can give a message.
Checking the length of user inputWe have a form and we will check the input once the button is clicked. We will check the length of the string entered by user and accordingly give a message by using div layer.
Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
|
More on Loops and Variables |