JS statements are generally divided into sequential, branching and looping statements:
Branch contains if and switch statements
The IF statement has 4 kinds of wording:
1.if ()
if (a>b)
{
When the condition is established, the execution
}
2.if () {}else{}
/*if (A>B)
{
Alert ("correct");
}
Else
{
Alert ("Error");
}*/
3.if () {} else if () {}
/*if (A>10)
{
Alert ("Too expensive!") ");
}
else if (a>5)
{
Alert ("You Can!" ");
}
Else
{
Alert ("Too cheap!" ");
}*/
Nesting of 4.if
if (a>b)
{
if (a=5)
{
if (a>3)
{
Alert ("equal");
}
}
}
Switch's wording:
Switch (a)
{
Case 1:
Alert ("1");
Case 2:
Alert ("2");
Case 3:
Alert ("3");
Case 4:
Alert ("4");
Break
Case 5:
Alert ("5");
Case 6:
Alert ("6");
Default:alert ("Condition not satisfied!") ");
}
To loop with a for statement, use the following notation:
An even number between output 0-10
/*for (Var i=0;i<=10;i=i+2)
{
alert (i);
if (i%2==0)
{
alert (i);
}
}*/
Output 0-100 between the and
var a = 0;
for (Var i=0;i<=100;i++)
{
A=a+i;
alert (a);
}
alert (a);
Java Journey-js-Statement