Conditional Statement
When we write our code, we need to ask question or make conditional statement so not all our code is executed. For example, if the balance account is larger than specific number, you allow your code to execute some statements, otherwise just ignore it. We need to have code that sometimes runs, and sometimes does not, depending on the condition of the program at the time.
We begin with 'if' statement which is found in almost all programming language. The condition is always resulting in true or false.
var a = 1;
if(a < 10)
{
alert(a);
}
In that code, variable 'a' will be printed because is less than 10, which means true. But what about this code :
var a = 10;
if(a < 10)
{
alert(a);
}
Yes, the condition statement will be ignored completely because 'a' is not less than 10, which means false.