I have an array of objects called cars
that contains search result listings. In each listing there is an attribute called data-price
.
Array Object Example
<li xmlns="http://www.w3.org/1999/xhtml" id="listing-ECAR-R-EY-MCOO001-EY-MCOO001" data-price="94.03"></li>
I'm wondering how I can get the lowest data-price value? And the average data-price value from the array of cars?
Code:
// This prints out each price value
cars.forEach(function(element) {
console.log(element[0].getAttribute("data-price"));
});