Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!