Skip to content

Назарова Галина#9

Open
galkadaw wants to merge 5 commits intourfu-2016:masterfrom
galkadaw:master
Open

Назарова Галина#9
galkadaw wants to merge 5 commits intourfu-2016:masterfrom
galkadaw:master

Conversation

@galkadaw
Copy link
Copy Markdown

No description provided.

@honest-hrundel
Copy link
Copy Markdown

🍅 Пройдено тестов 10 из 24

@honest-hrundel
Copy link
Copy Markdown

🍅 Пройдено тестов 10 из 24

@honest-hrundel
Copy link
Copy Markdown

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

Comment thread lib.js Outdated
for (var j = 0; j < newLevelFriends.length; j++) {
friendsWithLevel.push(
{
friend: getFriendByName(friends, newLevelFriends[j]),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

было бы круто избавиться от этой функции, например храня в newLevelFriends не только имена а сразу объект друга

Comment thread lib.js
}

friendsWithLevel.sort(function (friendOne, friendTwo) {
if (friendOne.level > friendTwo.level) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

можно красиво сделать через тернарник

Comment thread lib.js Outdated
function Iterator(friends, filter) {
console.info(friends, filter);
if (!Filter.prototype.isPrototypeOf(filter)) {
throw new TypeError();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

лучше написать здесь ошибку

Comment thread lib.js Outdated
if (!Filter.prototype.isPrototypeOf(filter)) {
throw new TypeError();
}
this.friendsWithLevel = friendsLevel(friends).filter(function (friend) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

все методы нужно разместить в прототипах

@FrodoTheTrue
Copy link
Copy Markdown

🍅

@honest-hrundel
Copy link
Copy Markdown

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

@FrodoTheTrue
Copy link
Copy Markdown

🚀

@honest-hrundel honest-hrundel assigned dzlk and unassigned FrodoTheTrue Dec 3, 2016
Copy link
Copy Markdown

@dzlk dzlk left a comment

Choose a reason for hiding this comment

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

🍅

Comment thread lib.js
};
}

MaleFilter.prototype = Object.create(Filter.prototype);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❗️ Свйоство (new MaleFilter()).contructor теперь указывает на Filter

Comment thread lib.js

Iterator.prototype.friendsLevel = function (friends) {
var bestFriends = friends.filter(function (friend) {
return friend.hasOwnProperty('best') && friend.best;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В принципе, можно заменить на Boolean(friend.best)

Comment thread lib.js
for (var i = 0; i < friendsWithLevel.length; i++) {
var newLevelFriends =
friendsWithLevel[i].friend.friends.reduce(function (newLevelFunction, friendName) {
if (namesOfFriends.indexOf(friendName) === -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.

❗️ Лучше держать объект имен, по нему скорость поиска значительно выше

Comment thread lib.js
}
);
namesOfFriends.push(newLevelFriends[j].name);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❗️ Обычно цикл for используется для предсказуемого числа итераций. Тут явно не тот случай.
Я бы предложил использовать очередь, из которой выталкивать по одному элементу. Имеется фор по friendsWithLevel

Comment thread lib.js
}

return (friendOne.friend.name > friendTwo.friend.name) ? 1 : -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.

❗️ А можно без этой сортировки в конце обойтись?

@dzlk dzlk removed their assignment Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants