����� 5
�� 6: ����� �-JavaScript ��� ������ ������.
���� ��-JavaScript ��� ����, ���� ���� ����� �� ����� ��� ����. ���� ���� ���� ������ ��� ������ ������ �� ���� ���, �� �� ���� �� �� ���� ����� ��� 80/20. ��� ���� 80 ������ ������� �� ������ �-20 ������ �������� �� ������ ���� ����. ����� ������� �� �-20 ���� ������� ��� ��� ���� ����, ����� ����� ��� �� ���� ���� ������. �����, �� �-JavaScript ��� �� ���, �� ���� ����� ���� ������ ���� ���� ����� �� ��� ����� ���� ��� ����. ��� �� ����� ���� ����� ���� ���� ���, ��� �� ��� ���� ���� ���� �� ���� ��������.
��� ���� ������ ������ ��� ������ ������� ���� ���� ���.
���� �� ���� ������ ���� ���� ���� ������.
����� ������ ����� ������ ��� ����� ��� ����� ����� ���� �����. �� ����� ����� ����� ������ �� ��� ���, ��� ��� ���� ���� ���� ���� �����. �����:
var index = 0;
while (index <10)
{
var the_date = new Date();
var the_day = the_date.getDay();
var the_name = prompt("what's the kid's name? " ,"");
alert("On " + the_day + " " + the_name + " is a very special person.");
index++;
}
����� ��� ������� 10 ����� ���� ������. �� ��� ��� ����� ���� ��� ��, ����� �� �� ����, ��� ������ "���� ���, �� ���� ��� �� ��� ����� ����".
��� ���� �� ��� ���� �����. ����, ��� ���� ����. ��� ��� ���� ���� �� ��� ������ �������� ���� �����. ����� ������ ���� 10 �����, ���� ���� ������� ����� ��� �"� ������ ��� ��� ����:
var index = 0;
var the_date = new Date();
var the_day = the_date.getDay();
while (index < 10)
{
var the_name = prompt("what's the kid's name? " ,"");
alert("On " + the_day + " " + the_name + " is a very special person.");
index++;
}
��� �� ������ if-then-else ���� ������ ���� ������.
���� ������� if-then-else �������� ���� ��� ������ ���� ����, ��� ���� ����� �� ���� ������� ��� ������� �"� �� ����� �� ��� ���� ���� ����� ������ ������:
var pet = prompt("what kind of pet do you have?", "");
if (pet == "cat")
{
doCatStuff();
} else if (pet == "dog")
{
doDogStuff();
} else if (pet == "bird")
{
doBirdStuff();
} else if (pet == "lizard")
{
doLizardStuff();
}
������, ����� �- if ���� ���� ����� ������ ��, ���� �� ����� ����� �- lizard �- dog.
���� ��� ����� ������� ������� �� ����.
�� ��� ���� �� ���� ���� ����� ����� ������, ��� var pi = 22/7, ��� ����� ���� ���� ��� ��� ��� ���� ����� ���� ��� ����� ������. ������, �����:
function theArea(radius)
{
var pi = 22/7;
var area = pi * radius * radius;
return area;
}
function theCircumference(radius)
{
var pi = 22/7;
var circumference = 2 * pi * radius;
return circumference;
}
var pi = 22/7;
function theArea(radius)
{
var area = pi * radius * radius;
return area;
}
function theCircumference(radius)
{
var circumference = 2 * pi * radius;
return circumference;
}
��, ��� ���� ���� ����� ������ ������ ��, ������ ��� ����� ��. ��� ����, ������ ��� ���, ��� ����� �� ����� ���� ������ ���, �� ����� ���� ���� ��. �"� ����� ��� ��� ��� ����, ��� ���� ����� �����. ����� ��� ���, ����, �� ���� ����� ����� ��� ������ ����. �� �� ��� ��� ����� ���� ���� ���� �� ���� ��� ���� ����. �� �� ������, ��� ����� ��� ����� ��� ����� �������� ������ ��� ���.
���, �����, ���� ����� ����� ������ �� ����, ��� ����� ���� �� �� ���� �-JavaScript ������ ������. �� ����� �� ���, ������ ����� ��� ����� �������� ��������, ����� ���� �-JavaScript . �����, �� ����� �� ��� ����� ������� ����� �������� ��� ������� ���� ����� ����, ��� ������ ����� ������ �������: JavaScript acolyte. ���� �������� ������ ��� ����� �� ������.
���� ������ ���
��� ��� «--
|