0

I want to sort this array depends on a specific key.

const test = [
    {
       id: 1,
       capPrice: 1000
    },
    {
       id: 1,
       twoPrice: 2000
    },
    {
       id: 1,
       twoPrice: 4000
    }
]

And I want to get the result as below.
Depends on the specific key, it will sum his own value.

const test = [
    {
       id: 1,
       capPrice: 1000,
       twoPrice: 6000
    }
]

I tried to make this. But I didn't solve this algorithm yet.
Could you give me some advice? Thank you so much for reading it.

Thomas Jason
  • 538
  • 2
  • 7
  • 18

0 Answers0