Skip to content

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.

3 participants