• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Tuesday, July 3, 2012

TUTORIAL JAVASCRIPT - STATEMENT FOR NEWBIE

Hi...!! Welcome...
in We Are Knowledge....

Haha.. Power full... Yeah.. in order to we In to fire...

Ok... This time I want giving you tutorial "javascript" about "statement"...
In javascript to be found Two statement...

1. Conditional

  • IF
  • IF - ELSE
  • IF - ELSE IF - ELSE
  • SWITCH
2. Looping
  • FOR
  • WHILE

1. Conditional
       Conditional is statement for correct coding in order to have two result "true" or "false"... And If conditional "true" Program want continue.. And if "false" program want stop or return, until result "true"..

A.IF

Sintaks :
if (conditional)
{
True Result
}

Example :

Copy This Cding  your aplication

<html>
<head>
<title>Statement For Newbie</title>
</head>
<body>
<script>
var x = 10;
if (x == 10)
{
alert("Yes.. Number is 10");
}
</script>
</body>
</html>

And if done.. save with safe as type "HTML"..
And Double click...

This Result :




B. IF - ELSE

Sintaks :
If (conditional)
{
Coding Is True
}
else
{
Code Is False
}

Example:

Copy This Cding  your aplication

<html>
<head>
<title>Statement For Newbie</title>
</head>
<body>
<script>
var x =5;
if (x  == 7)
{
alert("The Number is  7)
}
else
{
alert("The Number is  Not 7)
}
</script>
</body>
</html>

And if done.. save with safe as type "HTML"..
And Double click...

This Result :




C. IF - ELSE IF - ELSE

Sintaks:
If(conditional 1)
{
Code Number 1 Is True
}
else if(conditional 2)
{
Code Number 2 Is True
}
else(conditional 3)
{
Code Number 3 Is True
}

Example:

Copy This Cding  your aplication

<html>
<head>
<title>Statement For Newbie</title>
</head>
<body>
<script>
var x = 89;
if (x >=  85)
{
alert("A")
}
else if (x >=  65)
{
alert("B")
}
else (x >=  40)
{
alert("C")
}
</script>
</body>
</html>

And if done.. save with safe as type "HTML"..
And Double click...

This Result :



D. SWITCH
Switch is Statement Avail if to be found many conditional.. Likely "IF"

Sintaks:
switch(expression)
{
case conditional_1:
    Code Number 1 Is True;
    break;
case conditional_2:
    Code Number 2 Is True;
    break;
case conditional_3:
    Code Number 3 Is True;
    break;
}

Example:

Copy This Cding  your aplication

<html>
<head>
<title>Statement For Newbie</title>
</head>
<body>
<script>
var x = "2";
switch (x)
{
case "1":
alert("Number 1");
break;
case "21":
alert("Number 2");
break;
case "3":
alert("Number 3");
break;
}
</script>
</body>
</html>

And if done.. save with safe as type "HTML"..
And Double click...

This Result :



1. Looping
    Looping is statement was present by javascript for more eazy in alogaritma... Usually statement for was have value... and want to be continue until conditional to fill..

A. FOR

Sintaks:
For(start; conditional; Increasse)
{
We Are Knowledge
}

Example:

Copy This Cding  your aplication
<html>
<head>
<title>Statement For Newbie</title>
</head>
<body>
<script>
for (a = 1; a <= 10; a++)
{
document.write("   We are Knowledge   ");
}
</script>
</body>
</html>

And if done.. save with safe as type "HTML"..
And Double click...

This Result :



A. WHILE
While is Statement to continue until conditional to fill..

sintaks:
while(conditional)
{
We Are Knowledge
}

Example:

Copy This Cding  your aplication
<html>
<head>
<title>Statement For Newbie</title>
</head>
<body>
<script>
var a = 0;
while(a <= 5)
{
document.write("We Are Knowledge"+"<br/>");
a++;
}
</script>
</body>
</html>

And if done.. save with safe as type "HTML"..
And Double click...

This Result :



Ok... I hope you understand with my tutorial..
Oh yes... read too My other article about javascript...

Thanks for you...
Thanks for visitors....

See you leter...

No comments:

Post a Comment