Answer the question
In order to leave comments, you need to log in
How to return and add the values of specific keys in an array?
There is an array
const _products = [
{'id': 1, 'title': 'iPad 4 Mini', 'price': 500.01, 'inventory': 2},
{'id': 2, 'title': 'H&M T-Shirt White', 'price': 10.99, 'inventory': 10},
{'id': 3, 'title': 'Charli XCX - Sucker CD', 'price': 19.99, 'inventory': 5}
]
inventory
and display the total amount?
Answer the question
In order to leave comments, you need to log in
var inventorires = 0;
_products.forEach(function(product){
inventorires += product.inventory;
});
alert(inventorires);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question