����� 4
�� 3: ������ �����.
���, ����� �� ������ ���� ���� ��� ����. ���� ���� �� �� ��, �� ��� ������� ����� �� �� ���� ������ ������ ���.
���� ������ �������� �� �-JavaScript, ����� ������� �� ��� ������ �� ������.
var password="pass the wrench";
var answer;
����� ������� �� ������ �������, �������� �� ������ answer. ����� ���� ���� ������ �� ������ answer ���. ������ ����� �� ������� �����:
while (answer != password)
{
answer = prompt("What's the woyd?","");
}
���� ����� �- while, ���"� ������ ����� ����:
while (some test is true)
{
do the stuff inside the curly braces
}
������ ���� ������: "�� ��� ������ ���� ���� ������, ���� �� ������� �������". ������ ����� ������ ����� �� ������� ���� ������� ��������� �� ������ ����� ��� false. ����� �� ����� ���� ����� �� �����, ������� ����� ������ ��� ������ (����: pass the wrench).
����� ������ ������ �� answer ����, ������ ��� ��� ����� (password!=answer) ��� ����� �� ������ ����� ����� ������ ������. ����, �- answer ����� ��� ���� ����� �- while �� ���� �� ��� ���� ������� ������ ������. �� ����� ���� ���� ���� �� ��� ������ �� "".
����� �������� ����� ������, ������ ��� ���� ���� ������ ����� �� ������ �������� ��� ���� �����. ��� ��� ���� ����� ����� ������ while, ����� ���� ����� ���.
���� ������ ���
��� ��� «--
|