I need to replace the order_id
value with parentOrder_id
in the array. When I try this, only the first record from the array is displayed.
How do I display all the entries in an array?
let nom_name = ""
let quantity = 0
let cost = 0
const array = [
{nom_name: "Test", cost: 500, quantity: 1, order_id: 1},
{nom_name: "35634", cost: 100, quantity: 1, order_id: 2}
]
array.forEach(o => {
nom_name = o.nom_name,
quantity = o.quantity,
cost = o.cost
})
const arr = [{
nom_name: nom_name,
quantity: quantity,
cost: cost,
parentOrder_id: 4
}]
console.log(arr)