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

182
Visualizações
I'm trying to use reduce high order function in my javascript code but keeps giving me #<Object> not a function

I'm doing an assignment using javascript language for educational purposes, but i'm a beginner. I'm having some problems trying to use reduce function.

What i'm trying to do is to use reduce to filter the following.

"Receive a string array in propNames and an object array in objs. Return a new object array with objects produced by applying the filterProperties function with propNames to each object in objs."

I already code filterProperties and its working fine to match propNames with only one object. I leave the code down below:

function filterProperties(propNames, obj) {
    let output = {}
    let objKeys = Object.keys(obj);
    const matchingElems = propNames.sort().filter(elem => objKeys.includes(elem))
    matchingElems.forEach(elem => output[elem] = obj[elem])
    return output
}

So just to sum up, i would like to use reduce to iterate and output an array with the properties matching propNames and objs.

My code is not working, i'm a complete beginner and I didn't understand well how to use reduce function. I leave my code below, so that anyone can help me solving this issue.

function filterPropertiesN(propNames,objs) {
    objs.reduce(filterProperties(propNames, objs))
 }

many thanks in advance!

about 4 years ago · Juan Pablo Isaza
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