DEV Community

Malith Pamuditha Fernando
Malith Pamuditha Fernando

Posted on

Merge multiple objects in node.js

I create below objects,

products = [
    {id:1, name: a},
    {id:2, name: b},
]

prices = [
    {id:1, month:1, price:1},
    {id:1, month:2, price:1},
    {id:2, month:1, price:1},
    {id:2, month:2, price:1},
]

so i want output as product prices,

product_prices = [
    {id:1, name: a, prices: [{id:1, month:1, price:1},{id:1, month:2, price:1}]}, 
    {id:2,

Top comments (0)