��� ����: ����� ����� / ����� 4 / �� 2
 


������ �� ��� �- JavaScript
 


���� ������ ��:
1: ����� ������ 4
2: ���� �������
3: ������ �����
4: ��� �� ������ while
5: ������ for
6: ������ �������
7: ������ ������
8: ������
9: ������ �������
10: ������ �- DOM
11: ��������
12: �������� void
13: �������
14: �������� �������
15: ����� ��������
16: ����� ����� 4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

����� 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, ����� ���� ����� ���.

���� ������ ���

��� ��� «--

 
       
       
   
 
 

���� ����
����� �����
����� �����
����� ������
����� ���
��� ����