Reputation: 11
If I need to get 59, how can I do it?
data = [
{name: 'AK', price: 50, amount: 1, total: 50},
{name: 'UMP', price: 59, amount: 1, total: **59**}
]
Upvotes: 0
Views: 80
Reputation: 93
if you are looking solution with Array iteration
for (let dt of data) {
console.log(dt.total);
}
if you are looking for a solution on condition-based then
data.find(dt => dt.name === 'UMP').total;
Upvotes: 1
Reputation: 387
If data array is static:
data[1].total
else
const getObjectHavingTotal59 = this.data.filter(e=>{
return e.total===59;
})
then
getObjectHavingTotal59[0].total;
Upvotes: 0