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

199
Vistas
unable to change the items based on id and expected result should be in output format and it should return proper value with updated value

unable to change the items based on id and expected result should be in output format

const items = [
        { id: 1, value: "first" },
        { id: 2, value: "second" },
        { id: 3, value: "third" }
      ];
      const expectedOutput = [
{ id: 1, value: "first" },
        { id: 2, value: "newvalue" },
        { id: 3, value: "third" }
]
      function getData(value, id) {
       return items.map((_each)=> {
         if(_each.id === id) {
           //need to update items with id=2
         }
       })
      }
      
      console.log(getData("newvalue", 2))

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

0

const items = [
        { id: 1, value: "first" },
        { id: 2, value: "second" },
        { id: 3, value: "third" }
      ];
      const expectedOutput = [
{ id: 1, value: "first" },
        { id: 2, value: "newvalue" },
        { id: 3, value: "third" }
]
      function getData(value, id) {
       return items.map((each)=> {
         if(each.id === id) {
           //need to update items with id=2
           return {...each, value}
         }else{
               return each }
       })
      }
      
      console.log(getData("newvalue", 2))

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