Skip to content

Instantly share code, notes, and snippets.

@TimBlock
Created January 15, 2016 12:00
Show Gist options
  • Save TimBlock/fa3f194c69505f9b2eaa to your computer and use it in GitHub Desktop.
Save TimBlock/fa3f194c69505f9b2eaa to your computer and use it in GitHub Desktop.
function average(array) {
function plus(a, b) { return a + b; }
return array.reduce(plus) / array.length;
}
var century = people(ancestry,function(person){
return Math.ceil(person.died / 100);
});
for(var cent in century){
var ages = century[cent].map(function(person) {
return person.died - person.born;
});
console.log(cent + ": " + average(ages));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment