Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gkoehler/5223862 to your computer and use it in GitHub Desktop.
Save gkoehler/5223862 to your computer and use it in GitHub Desktop.
// Macbook air 2011 product page: http://www.amazon.com/gp/offer-listing/B005CWHZP4/sr=/qid=/ref=olp_page_next?ie=UTF8&colid=&coliid=&condition=used&me=&qid=&shipPromoFilter=0&sort=sip&sr=&startIndex=30
// Went to all three pages under the "used" tab and called this function on the console:
Array.prototype.slice.call( document.querySelectorAll('.result .price')).map(function(el) { return parseInt(el.innerText.replace('$','').replace(',','')); })
// this generated the following array of prices:
var prices = [600, 750, 800, 800, 825, 850, 889, 896, 899, 898, 899, 900, 935, 944, 950, 950, 950, 959, 975, 999, 999, 999, 1000, 1000, 1000, 1000, 1049, 1099, 1100, 1100, 849, 1100, 1150]
// finding the average price:
var avg = prices.reduce(function(prev, cur) {
return prev + cur;
}) / prices.length;
// output: 942.82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment