showing results for - "javascript how to push a key value pair into a nested object array"
Federico
24 Mar 2019
1arr = [
2  {
3      "id": 1,
4      "status": "pending",
5      "menues": [
6          {
7              "title": "Coke",
8              "price": "200"
9          }
10      ]
11  },
12  {
13      "id": 2,
14      "status": "delivered",
15      "menues": [
16          {
17              "title": "Pepsi",
18              "price": "120"
19          }
20      ]
21  }
22];
23
24const res=arr.map(nested =>({ id:nested.id, menues:
25  nested.menues.map(menu =>({...menu,status:nested.status})) }));
26console.log(res);