filter a Json by date in javascript

Asked

Viewed 29 times

0

I need to create the function that returns the expired boletos in relation to "data_expiration" and "30-07-2021" but I need to create this without changing the rest of the code beyond the existing function "filterSoultlyBoletosNoVencidos". I need to do this only by changing the previously created function. Someone can help me?

function buscaBoletos() {
  return [
    {
      "id": "1233559",
      "data_emissao": "2021-06-02",
      "data_vencimento": "2021-06-10",
      "valor_aberto": "89.90",
      "documento": "25523",
      "linha_digitavel": "23795246029000016306404004566909187180000007990",
      "link": "https://a2ed55ac-6ddd-4deb-baa4-a10596b33d6c.s3.us-south.cloud-object-storage.appdomain.cloud/53dfea40-d7f5-4e55-82db-f3a2135731c8/700196565605000000000500000007211778140000008990.pdf"
    },
    {
      "id": "1233560",
      "data_emissao": "2021-06-02",
      "data_vencimento": "2021-07-10",
      "valor_aberto": "89.90",
      "documento": "25524",
      "linha_digitavel": "33795246029000016306404004566909187180000007990",
      "link": "https://a2ed55ac-6ddd-4deb-baa4-a10596b33d6c.s3.us-south.cloud-object-storage.appdomain.cloud/53dfea40-d7f5-4e55-82db-f3a2135731c8/700196565605000000000500000007211778140000008990.pdf"
    },
    {
      "id": "1233561",
      "data_emissao": "2021-06-02",
      "data_vencimento": "2021-08-10",
      "valor_aberto": "89.90",
      "documento": "25525",
      "linha_digitavel": "43795246029000016306404004566909187180000007990",
      "link": "https://a2ed55ac-6ddd-4deb-baa4-a10596b33d6c.s3.us-south.cloud-object-storage.appdomain.cloud/53dfea40-d7f5-4e55-82db-f3a2135731c8/700196565605000000000500000007211778140000008990.pdf"
    },
  ];
}

function filtraSomenteBoletosNaoVencidos(boletos) {
  return {}; //Preciso implementar o algoritimo aqui

const boletos = buscaBoletos();
const boletosNaoVencidos = filtraSomenteBoletosNaoVencidos(boletos);
console.log("Boletos não vencidos:", boletosNaoVencidos)
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.