-
Notifications
You must be signed in to change notification settings - Fork 11
Задание второй лекции #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
*Возвращает объект Event | ||
*@param {Number | Date} start Начало события | ||
*@param {Number | Date} end Конец события | ||
*@param {String} name Имя события | ||
*@param {String} place Место проведения | ||
*@param {String} repeat["Нет", "Каждый день", "Каждую неделю", "Раз в 2 недели", "Каждый месяц", "Каждый год"] Повтор | ||
*@param {String} member[] Участники | ||
*@param {String} reminder["В момент события", "За 5 минут", "За 15 минут", "За 30 минут", "За 1 час", "За 2 часа"] Напоминание | ||
*@param {Number} gps[longitude, latitude] GPS координаты места | ||
*@param {String} note Заметки | ||
*@example | ||
*Event(new Date('2011-10-10T14:48:00'), | ||
* new Date('2011-10-10T15:48:00'), | ||
* "Деловая встреча", | ||
* "г. Екатеринбург, ул. Уральская, д. 67", | ||
* new []("Каждый день"), | ||
* new []("Беднева Дарья", "Петрова Марина", "Беляева Анастасия"), | ||
* new [](За 1 час), | ||
* new [](56.855636, 60.636671), | ||
* "Принести с собой ноутбук.") | ||
* | ||
*@return {Object} | ||
*/ | ||
function Event(start, end, name, place, repeat, member, reminder, gps, note) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. У функции много аргументов подумай как можно уменьшить их число. |
||
"use strict"; | ||
return { | ||
"start": +start, | ||
"end": +end, | ||
"name": name || "Событие", | ||
"place": place || "Город, улица, дом", | ||
"repeat": repeat, | ||
"member": member[], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Будет ошибка. Можно проверить просто тип параметра. На тип данный можно проверить поэлементно На вхождение в "словарь" можно проверить так var availableRemainders = {
"В момент события": true,
"За 5 минут": true
};
reminder = availableRemainders[reminder] ? reminder : void 0 |
||
"reminder": reminder, | ||
"gps": gps, | ||
"note": note || "Заметки" | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
*���������� ������ Event | ||
*@param {Number | Date} start ������ ������� | ||
*@param {Number | Date} end ����� ������� | ||
*@param {String} name ��� ������� | ||
*@param {String} place ����� ���������� | ||
*@param {String} repeat["���", "������ ����", "������ ������", "��� � 2 ������", "������ �����", "������ ���"] ������ | ||
*@param {String} member[] ��������� | ||
*@param {String} reminder["� ������ �������", "�� 5 �����", "�� 15 �����", "�� 30 �����", "�� 1 ���", "�� 2 ����"] ����������� | ||
*@param {Number} gps[longitude, latitude] GPS ���������� ����� | ||
*@param {String} note ������� | ||
*@example | ||
*Event(new Date('2011-10-10T14:48:00'), | ||
* new Date('2011-10-10T15:48:00'), | ||
* "������� �������", | ||
* "�. ������������, ��. ���������, �. 67", | ||
* new []("������ ����"), | ||
* new []("������� �����", "������� ������", "������� ���������"), | ||
* new [](�� 1 ���), | ||
* new [](56.855636, 60.636671), | ||
* "�������� � ����� �������.") | ||
* | ||
*@return {Object} | ||
*/ | ||
function Event(start, end, name, place, repeat, member, reminder, gps, note) { | ||
"use strict"; | ||
return { | ||
"start": +start, | ||
"end": +end, | ||
"name": name || "�������", | ||
"place": place || "�����, �����, ���", | ||
"repeat": repeat, | ||
"member": member[], | ||
"reminder": reminder, | ||
"gps": gps, | ||
"note": note || "�������" | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
так не получится
new []("Беднева Дарья", "Петрова Марина", "Беляева Анастасия")
можно просто["Беднева Дарья", "Петрова Марина", "Беляева Анастасия"]
https://speakerdeck.com/u/azproduction/p/2-liektsiia?slide=30