����� 5
�� 5: ����� ����� ���.
����� ������ ��� ���� ��� ����� ����� ���� �����, ��� ������. �� ��� �� ���� ���� �� �� ������ �� ����� ��� ��� ����� ���� �� �- JavaScript ���, ����� ��� ���� ���� ����. ��� ����� ��� ���� ����, ���� ���� ����� ������. ����� ���� ��� ����, ��� ��� ����� ��� ���� ��� �� ��� �� ��� ��� ����. ��� ����� ���� ����� ��� KISS - Keep It Simple Sweetie
��� ������ ������ ��� ����� ����� ���� ����� ������. ������ ������� ���� ����� �� ������ ���� ���� ���� �����. ���� ����� �� ������, ��� ���� ����� �� ���� ��� ��� ��� ���. ��� ����� �� ������� ������ ���� ��.
��� �����: ����� ��������:
//function beSassy()
// beSassy asks for a user's name, chooses a random
// insult and returns an alert box with the user's name and the
// insult.
function beSassy()
{
// first write a list of insults
//
// next get the user's name
//
// then choose a random insult
//
// finally, return the personalized sass
//
}
//function beSassy()
// beSassy asks for a user's name, chooses a random
// insult and returns an alert box with the user's name and the
// insult.
function beSassy()
{
// first write a list of insults
//
var the_insult_list = new Array;
the_insult_list[0] = "your shoe lace is untied";
the_insult_list[1] = "your mama!";
the_insult_list[2] = "it's hard to be insulting";
// next get the user's name
//
var the_name = prompt("What's your name?", "");
// then choose a random insult
//
var the_number = Math.random() * 5;
var insult_number = parseInt(the_number);
var the_insult = the_insult_list[insult_number];
// finally, return the personalized sass
//
alert("Hey " + the_name + " " + the_insult);
}
������ �� �� ����� ���� ��, �� �� ������ ���� ����� ���� ���� ����, ��� �� ����� �� ����� ������ ���� ���� � �"� ����� ������ ����� ����� ����� ����� ����. ����� ��� ����� ����� ������� ���� ����� ����� ������ ��������.
������ ... ���� ���� �� ������ ��� �� ����� ����� ������ (;)
����� ��� ���� ����� ���, ���� ���� ����� �� ����� ����� �� ������� ��� �� ����� ����� ���� ��� ����� ����� ����� ����� ��� ���. ��� ������� �����, ������ ����� ���� �� ��� ����� ������ �����.
��� ������ ������� ��� "var" ��� �� �� �� �� ���� ���� �� ����� ���.
����� �� ������� ��� �"� ����� �-"var" ����� �� ������ �������� ��� ����� �� ������ �� ������� ����, ��� ����� ����.
���, ����� ���� ���� ��� �����, ��� ���� ��� ����� �-JavaScript ��� ���� ���.
���� ������ ���
��� ��� «--
|