Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda