Skip to content

Instantly share code, notes, and snippets.

@gingerrific
Created May 11, 2014 00:27
Show Gist options
  • Save gingerrific/c5b78503b3f70404c482 to your computer and use it in GitHub Desktop.
Save gingerrific/c5b78503b3f70404c482 to your computer and use it in GitHub Desktop.
var averagePrice = items.reduce(function (arrayZero, arrayOne) {
console.log((arrayZero.price + arrayOne.price)/items.length);
return {price: arrayZero.price + arrayOne.price};
})
averagePrice.price = +(averagePrice.price/items.length).toFixed(2);
// averagePrice.price = +(averagePrice.price).toFixed(2);
console.log("The average price is $", averagePrice.price);
items.forEach(function (array) {
if (array.currency_code == "GBP") {
console.log(array.title + "Costs £" + array.price)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment