Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
Array.filter() is not working - the filter isn't executing

I am trying to filter an array of objects with 3 filters. The first two execute as expected but the last one does not execute at all. There is a lot of code in total so here is the Github link: Github repository

 function FormatSearch() {
        return search.value.toLowerCase().replace("č", "c").replace("ć", "c").replace("š", "s").replace("ž", "z")
    }

    function FormatLocation() {
        return location.value.toLowerCase().replace("č", "c").replace("ć", "c").replace("š", "s").replace("ž", "z")
    }
    let filtered = allPosts
        //filter po imenu/opisu
        .filter(post => post.title.includes(FormatSearch()) || post.description.includes(FormatSearch()))
        //filter po kategoriji
        .filter(post => filters.includes(post.category) || filters.length == 0)
        //filter po lokaciji
        .filter(post => async function(){
            let owner = await post.getOwner()
            return Boolean(owner.info[1].includes(FormatLocation()) || FormatLocation() == "")
        })
    
    document.getElementById("posts").innerHTML = ""
    filtered.forEach(post => {
        post.addPost()
    })

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Agree to VLAZ, you can choose return a promise array and Promise.all them or use async/await in a for loop which basically has the same speed as filter.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda