-2

guys! i'm at a dead end(

I have an array of objects:

[{"All": "all"}, {"Success": "successCompleted"}, {"Refund": "refunded"}, {"Error": "error"}]

So, I need to get this from that array:

{All: "all", Success: "successCompleted, Refund: "refunded", Error: "error"}

But I can't find any pretty solution (

Please help someone!

John Red
  • 15
  • 3

1 Answers1

2

const input = [{"All": "all"}, {"Success": "successCompleted"}, {"Refund": "refunded"}, {"Error": "error"}]

const output = input.reduce((final, obj) => ({ ...final, ...obj }))

console.log(output)
Konrad
  • 21,590
  • 4
  • 28
  • 64