-
Notifications
You must be signed in to change notification settings - Fork 10
вторая домашка #8
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,39 @@ | ||
/** | ||
* Возвращает объект Event | ||
* | ||
* @param {Number|Date} start Начало события | ||
* @param {Number|Date} end Конец события | ||
* @param {String} [name="Событие"] Имя события | ||
* @param {String} [description="Описание"] Описание события | ||
* @param {Number} [number=1] Рейтинг события | ||
* @param {Boolean} [alarm=false] Нужно ли напоминание | ||
* | ||
* @example | ||
* Event(new Date('2011-10-10T14:48:00'), | ||
* new Date('2011-10-10T15:48:00'), | ||
* "Совещание") | ||
* | ||
* @return {Object} | ||
*/ | ||
function Event(start, end, name, description, rating, alarm) { | ||
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. Слишком много аргументов - подумай как уменьшить их число |
||
if (typeof(alarm) === "boolean") { | ||
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. typeof - оператор, а не функция - от скобок смысла нет |
||
var new_alarm = alarm; | ||
} else { | ||
var new_alarm = false; | ||
} | ||
if (typeof(rating) === "number") { | ||
if (rating > 5 || rating < 1) { | ||
var new_rating = 1; | ||
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. Лучше |
||
} else { | ||
var new_rating = rating; | ||
} | ||
} | ||
return { | ||
"start": +start, | ||
"end": +end, | ||
"name": name || "Событие", | ||
"description": description || "Описание", | ||
"rating": new_rating, | ||
"alarm": new_alarm | ||
}; | ||
} |
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.
Поехал код - проверь на табы и пробелы.