Recommand · October 14, 2021 0

Best way to combine two objects in Javascript

Closed. This question needs details or clarity. It is not currently accepting answers.


Want to improve this question? Add details and clarify the problem by editing this post.

Closed 1 hour ago.

Improve this question

I have two objects that I need to be combined as one, like in the example. Is there anyway of using mapping/destructing to achieve this?

const use = { A: 2, B: 3, C: 20 };

const capsAndUse = {
    A: { caps: 10, use: 2 },
    B: { caps: 10, use: 2 },
    C: { caps: 10, use: 2 },
};```