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

77
Vistas
JavaScript reduce fails when building key/value result inside arrow function

I am unable to use the JS reduce function to transform the following object:

obj = {
   "key1":"value1",
   "key2":"value2"
}

to this:

newObj = {
  "key1":{
     "S":"value1"
  },
  "key2":{
     "S":"value2"
  }
}

I am using the JavaScript reducer function for this transformation like this:

let newObj = Object.entries(obj)
    .reduce((result, entry) => {
        return {
            ...result,
            entry[0]: entry[1]
        }
    }, {})

But I get the following error:

            entry[0]: entry[1]
                                ^

SyntaxError: Unexpected token '['

How can I resolve this to transform the object?

about 4 years ago · Juan Pablo Isaza
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