Skip to content

Conversation

@KHYehor
Copy link

@KHYehor KHYehor commented Oct 7, 2018

Гит Игнор не ставил на лог файл, а так сделал как понял, жду вразумительных ревьюх.

class ArrayAdvanced extends Array {
constructor(array) {
super();
this.array = array.slice();
Copy link
Owner

Choose a reason for hiding this comment

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

Конструктор нужно переписать. Он должен иметь тот-же контракт, что и обычный Array. Сейчас - это объект со свойством array

this.array = array.slice();
}
specialSort(collection) {
if (collection.hasOwnProperty('sort')) collection.sort(this.array);
Copy link
Owner

Choose a reason for hiding this comment

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

Функция сортировки, а так же все остальные функции из опционального объекта - функции, которые перебирают один элемент массива. Они не должны сортировать сразу весь массив

Copy link
Author

Choose a reason for hiding this comment

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

как функция сортировки будет сортировать один элемент массива?

Copy link
Owner

Choose a reason for hiding this comment

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

Почитай про колбек в Array.prototype.filter: https://www.ecma-international.org/ecma-262/8.0/#sec-array.prototype.filter

Copy link
Owner

@machendos machendos left a comment

Choose a reason for hiding this comment

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

Всё ок, только куда делся фильтр?)

@KHYehor
Copy link
Author

KHYehor commented Oct 12, 2018

Как тебе такое Илон Маск? Функциональность и подход к задаче

@machendos
Copy link
Owner

Переименуй класс в AdvancedArray, а методы в unsideTransform для неизменяющего массив метода, и в sideTransform для изменяющего, и затем экспортируй его, поместив в объект: module.exports = { AdvancedArray }
Чтобы это всё дело само проверилось

@KHYehor
Copy link
Author

KHYehor commented Oct 13, 2018

методы в unsideTransform для неизменяющего массив метода, метод не изменяет массив в классе? он возвращает новый измененный массив?

@machendos
Copy link
Owner

Он не изменяет массив, однако возвращает массив-результат: первый и/или последний элемент массива, или вообще пустой массив

@machendos
Copy link
Owner

Можно реализовать только один, но назови его правильно

@machendos
Copy link
Owner

А файл в solve.js

@machendos
Copy link
Owner

screenshot_2018-10-13-15-47-22

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.

2 participants