Skip to content

Conversation

AnnaYasenova
Copy link

Implemented next methods: searchPos, remove, findFirst, findAll, find.


}

searchPos(searchPosition) {
Copy link
Member

Choose a reason for hiding this comment

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

Лучше itemAtPos(position)

findFirst(name) {
let current = this.first;

while (current !== null && current.name !== name) {
Copy link
Member

Choose a reason for hiding this comment

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

Можно даже current && current.name !== name

let position = 0;

if (this.length < 0 || removePosition >= this.length) {
throw new Error('Position out of bounds.');
Copy link
Member

Choose a reason for hiding this comment

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

Не принято ошибки бросать по таким поводам, лучше вернуть ошибку или false из функции

let current = this.first;
let position = 0;

if (this.length === 0 ||
Copy link
Member

Choose a reason for hiding this comment

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

Форматирование этого длинного условия нужно как-то причесать. Я думаю, что если разобраться в сути, то условие будет покороче.

Copy link
Member

@tshemsedinov tshemsedinov left a comment

Choose a reason for hiding this comment

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

В общем все ок

}

return current;
}

remove(removePosition) {
remove(remPos) {
Copy link
Member

Choose a reason for hiding this comment

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

Лучше просто pos, не нужно дублировать имя функции в ее аргументах

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