3 ms·
Anecdata re: readership age: https://news.ycombinator.com/item?id=17636856 https://news.ycombinator.com/item?id=17636856 Eyeballing: average age seems to be mi
by adpirz 8y ago
Anecdata re: readership age: https://news.ycombinator.com/item?id=17636856 https://news.ycombinator.com/item?id=17636856
Eyeballing: average age seems to be mid 30's.
EDIT: 35.4, you can run in your console on that thread:
function averageAge(){
const ages = Array.prototype.slice.call(document.querySelectorAll('.commtext'))
.map(span => span.innerText)
.map(text => text.slice(0,2))
.map(firstTwo => Number(firstTwo))
.filter(n => !isNaN(n))
return ages.reduce((x,y) => x + y, 0) / ages.length
}
averageAge()
- faitswulff 8y agoPlayed a bit of code golf with your snippet, but can't figure out how to combine the .map(Number).filter(Number): let avgAge = [...document.querySelectorAll('.commtext')] .map(span => parseInt(span.innerText)) .map(Number) .filter(Number) .reduce((i,d,c, ages) => ages.reduce((x, y) => x+y) / ages.length)