Can someone please help me with some code to insert data into an existing array of objects so i have this array
[
{
"order_id": "241918",
"customer_name": "Marietjie",
"customer_surname": "Short",
"total_items": "44",
"completed_items": "17",
"percent_complete": 0.38636363636364,
"datetime_received": "2018-07-25 15:18:25",
"delivery_date": "2018-10-29",
"delivery_from": "12:00",
"delivery_to": "13:00",
"completed": "0",
"shopper": "joel"
},
{
"order_id": "281774",
"customer_name": "Ashleigh",
"customer_surname": "Hodge",
"total_items": "16",
"completed_items": "0",
"percent_complete": 0,
"datetime_received": "2018-10-04 15:59:19",
"delivery_date": "2018-10-29",
"delivery_from": "12:00",
"delivery_to": "13:00",
"completed": "0",
"shopper": null
}
]
i want to insert data from this array into the array above to replace the value of the percent_completed with the value of the array below.
["17", "0"]
so for the first
const newArray = a1.map((item,index)=>({...item,percent_complete:a2[index]})