Created
June 16, 2017 13:24
-
-
Save vectart/76109101d1a477be7a72a94e27b2d2c8 to your computer and use it in GitHub Desktop.
Booli slutpris median and average
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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