-
Notifications
You must be signed in to change notification settings - Fork 79
Мухаметов Денис #63
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?
Мухаметов Денис #63
Conversation
|
🍏 Пройдено тестов 19 из 19 |
|
@YuuKohaku обрати внимание: решено доп. задание |
|
🍏 Пройдено тестов 19 из 19 |
|
@YuuKohaku обрати внимание: решено доп. задание |
YuuKohaku
left a comment
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.
Математичный подход к решению, хорошая работа.
Местами методы трудно читаются, часто бросаются в глаза переприсвоения переменных и другие мелочи. Пока что помидор.
🍅
| let daysOfWeek = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС']; | ||
| let day = 0; | ||
| if (containsDay) { | ||
| let dayName = timeString.match(/(..)/)[1]; |
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.
В данном случае регулярное выражение излишне. Лучше substr.
| exports.isStar = true; | ||
|
|
||
| function parseTime(timeString, containsDay) { | ||
| let daysOfWeek = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС']; |
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.
Везде, где присвоение происходит один раз, имеет смысл использовать const вместо let.
| } | ||
|
|
||
| function convertRobbersSchedule(schedule) { | ||
| let newSchedule = []; |
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.
Через reduce получится короче и выразительнее.
|
|
||
| function addInterval(intervals, newInterval) { | ||
| let result = []; | ||
| intervals.forEach(interval => { |
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.
Тоже сделать через reduce.
| } | ||
|
|
||
| function removeScheduleIntersections(schedule) { | ||
| let unitedSchedule = []; |
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.
И тут тоже редьюсер напрашивается. )
| */ | ||
| exports.getAppropriateMoment = function (schedule, duration, workingHours) { | ||
| console.info(schedule, duration, workingHours); | ||
| schedule = convertRobbersSchedule(schedule); |
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.
Создать отдельную переменную в let для переприсвоений или обойтись без переприсвоений. Присваивать значение аргументам функции не стоит.
| if (this.startTimes.length === 0) { | ||
| return ''; | ||
| } | ||
| let daysOfWeek = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС']; |
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.
(Опционально)
А вот это можно и в константу наверх вынести.
| let daysOfWeek = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС']; | ||
| let time = this.startTimes[this.currentPos] + this.bankTimeZone * 60; | ||
| let day = daysOfWeek[Math.floor(time / (24 * 60))]; | ||
| time = time % (24 * 60); |
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.
Давай в отдельную переменную. Трудно следить за ходом мысли, когда содержимое переменной постоянно меняет смысл.
| */ | ||
| tryLater: function () { | ||
| return false; | ||
| if (this.currentPos === this.startTimes.length - 1 || this.startTimes.length === 0) { |
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.
Если this.startTimes.length вынести в отдельную переменную, условие получится короче, а смысл - понятнее. Кроме того, здесь можно использовать this.exists(), опционально.
| day = daysOfWeek.indexOf(dayName); | ||
| } | ||
| let numbers = timeString.match(/(\d+):(\d+)\+(\d+)$/); | ||
| let hours = Number.parseInt(numbers[1]); |
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.
Для таких целей хватит просто Number.
Загрузил в репозиторий 2016-го сначала, сейчас заметил и решил загрузить сюда