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

160
Vistas
How to find object in array by property value and reasign it's value?

Lets say i have an array with objects like this;

let employees = [{Name: 'Misha', Age: 25}, {Name: 'Karing', Age: 26}, {Name: 'Stephan', Age: 24}]

And i need to find some item in this object and change it's value. In order to find value i can use filter

events.filter(e => (e.Age === 25));

Should it be like this ?

events.filter(e => (e.Age === 25)).Age= 26;

But have do modify this value then? Let say i found someone who is 25 and i need to increase age to 26 ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could map your array and change values on the fly. Here's one way of approaching it.

let employees = [{Name: 'Misha', Age: 25}, {Name: 'Karing', Age: 26}, {Name: 'Stephan', Age: 24}]
let changeAge = (from, to) => employees = employees.map(e => (e.Age === from ? {...e, Age: to} : e));

changeAge(25, 26);
console.log(employees)

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