-
-
Save TimBlock/fa3f194c69505f9b2eaa to your computer and use it in GitHub Desktop.
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
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