Hi, I have a list for collection:
{
name: "orange",
price: NumberDecimal("4.99"),
discountPrice: NumberDecimal("3.99"),
newPrice: NumberDecimal("3.99"),
oldPrices:[
{
id: 1,
reason: "normalChange",
type: "price",
info: NumberDecimal("4.99")
},
{
id: 2,
reason: "normalChange",
type: "price",
info: NumberDecimal("3.99")
},
{
id: 3,
reason: "offer",
type: "price",
info: NumberDecimal("2.99")
},
{
id: 4,
reason: "normalChange",
type: "price",
info: NumberDecimal("4.50")
},
]
} ,
{
name: "bannana",
price: NumberDecimal("1.99"),
discountPrice: NumberDecimal("1.49"),
newPrice: NumberDecimal("1.39"),
oldPrices:[
{
id: 1,
reason: "normalChange",
type: "price",
info: NumberDecimal("24.99")
},
{
id: 2,
reason: "normalChange",
type: "price",
info: NumberDecimal("1.99")
},
{
id: 3,
reason: "offer",
type: "price",
info: NumberDecimal("2.99")
}
]
}
I want assign the last “info” value from the “oldPrices” that said “normalChange” at price,
in this answer:
I saw I can set a value from another element to another, but my problem is that I will not know which position of the array is the last value so i have to look for it. Could you help me with that? Thz