Skip to content

Instantly share code, notes, and snippets.

@vectart
Created June 16, 2017 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vectart/76109101d1a477be7a72a94e27b2d2c8 to your computer and use it in GitHub Desktop.
Save vectart/76109101d1a477be7a72a94e27b2d2c8 to your computer and use it in GitHub Desktop.
Booli slutpris median and average
var prices = [].concat.apply(Array, document.querySelectorAll('.search-list__column--info-2 .search-list__row:nth-child(2)')).map((e) => (parseInt((e.innerText || '').replace(' ', ''))), 10).filter((v) => (v > 1000)).sort((a, b) => a - b)
var sum = prices.reduce((previous, current) => current += previous);
var lowMiddle = Math.floor((prices.length - 1) / 2)
var highMiddle = Math.ceil((prices.length - 1) / 2)
averageAndMedian = [
sum / prices.length,
(prices[lowMiddle] + prices[highMiddle]) / 2
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment