0
<button
            onClick={() =>
              console.log(
                data.filter(
                  (element: apiData) =>
                    new Date(element.dataemissao) >= allDatesRange[0] &&
                    new Date(element.dataemissao) <= allDatesRange[length - 1],
                ),
              )
            }
          >
            data filteres
          </button>

It's working when I try get just dates that are bigger than the first value of allDatesRange array.

1
  • Can you try logging allDatesRange and make sure that the last date is greater than the first date? If the resulting array is empty it just means your filter condition isnt passing on any of the items Commented Dec 23, 2021 at 18:39

1 Answer 1

1

Try this.

<button
        onClick={() =>
          console.log(
            data.filter(
              (element: apiData) =>
                new Date(element.dataemissao) >= allDatesRange[0] &&
                new Date(element.dataemissao) <= allDatesRange[allDatesRange.length - 1],
            ),
          )
        }
      >
        data filteres
      </button>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.