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

154
Views
Return a value from a multi value object in Javascript based on criteria

Let's say I have an array of objects that looks like this:

  var obj1 = [{
          fullName ='Jon Doe',
          Name     ='Jon',
          age      ='17',
       },
       {
        fullName     ='Bob Smith',
        Name     ='Bob',
        age     ='34',
       }
   ]

If I have a var CustomerName = 'Jon', how can I possibly retrieve the age for Jon

  var cName = obj1.filter(function(item)){
      return item['age'] //?? Where item['name'] == customerName
  }

I am a little lost, am i on the right path? THanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're looking for something like this:

const filtered = (item) => {
  item.name === customerName
}

return obj1.filter(filtered).forEach((obj) => obj.age)
about 4 years ago · Juan Pablo Isaza Report
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!