Skip to content

homework_17 #21

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

homework_17 #21

wants to merge 1 commit into from

Conversation

NataliaButenko
Copy link
Collaborator

No description provided.

@@ -0,0 +1,117 @@
// TASK 0
const solution = arr => {
let newArr = [];
Copy link
Member

Choose a reason for hiding this comment

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

For at all, we could look at what we need from our array? We have to reduce its size but leave the same arguments.
So the first step will be to use .filter method.

A solution can look that way

  1. Take the element
  2. Take the element-index
  3. Take leaved part of an array to element-index
  4. Check if some elemnt in array is bigger than current element ( please note, there the same JavaScript method called .some
  5. if no one from that elements is bigger than current, leave it in array otherwise drop it

So I guess it could be solved with

.filter + .some from arrays method

//TASK1
class Carousel {
constructor() {
this.arrImg = ["bestsportcar170.jpg", "Acura-NSX-2016-2017-02.jpg", "ferrari_667_171011.jpg"];
Copy link
Member

Choose a reason for hiding this comment

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

Probably Carousel should not be worrying about picture names.

Our Carousel should only be responsible to know about

  • active element
  • changing elements left/right

That's all. And we have to apply it in several places in every app :) without any knowledge of pictures

}
};
let carousel = new Carousel();
carousel.buttonOperation();
Copy link
Member

Choose a reason for hiding this comment

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

that call seems weird - because it looks like the internals of Carousel.
As a developer who uses your carousel, I don't want to worry about buttonOperation. I want just apply your carousel and it works "out of the box"

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