Skip to content

Мухаметов Денис#63

Open
denexapp wants to merge 2 commits intourfu-2017:masterfrom
denexapp:master
Open

Мухаметов Денис#63
denexapp wants to merge 2 commits intourfu-2017:masterfrom
denexapp:master

Conversation

@denexapp
Copy link
Copy Markdown

Загрузил в репозиторий 2016-го сначала, сейчас заметил и решил загрузить сюда

@honest-hrundel
Copy link
Copy Markdown

🍏 Пройдено тестов 19 из 19

@honest-hrundel
Copy link
Copy Markdown

@YuuKohaku обрати внимание: решено доп. задание

@honest-hrundel
Copy link
Copy Markdown

🍏 Пройдено тестов 19 из 19

@honest-hrundel
Copy link
Copy Markdown

@YuuKohaku обрати внимание: решено доп. задание

Copy link
Copy Markdown

@YuuKohaku YuuKohaku left a 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];
Copy link
Copy Markdown

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 = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС'];
Copy link
Copy Markdown

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 = [];
Copy link
Copy Markdown

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 => {
Copy link
Copy Markdown

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 = [];
Copy link
Copy Markdown

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);
Copy link
Copy Markdown

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 = ['ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ', 'ВС'];
Copy link
Copy Markdown

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);
Copy link
Copy Markdown

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) {
Copy link
Copy Markdown

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]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для таких целей хватит просто Number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants