I have an object which has multiple properties and values. How do I fetch all at once?
In this below code the products have multiple values. I want to grab all the prices and want the sum of them using java script
The code as follows.
var products = [
{name:"anti-glair", price:100, quantity:200, status:"available"},
{name:"Lens", price:300, quantity:35, status:"Un-available"},
{name:"Optics", price:150, quantity:500, status:"available"}
];
I am trying like this
console.log(products.price);
But it is showing as not defined.
I want the all products sum as well.