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

75
Views
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
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!