SHARE
TWEET

Untitled

a guest Oct 20th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function average(array) {
  2.   function plus(a, b) { return a + b; }
  3.   return array.reduce(plus) / array.length;
  4. }
  5.  
  6. var byName = {};
  7. ancestry.forEach(function(person) {
  8.   byName[person.name] = person;
  9. });
  10.  
  11. var hasMotherAncestry = ancestry.filter(function(person) {
  12.     if(byName[person.mother] != null)
  13.       return person;
  14.   });
  15.  
  16. var arrayMomsAgeAtBirth = hasMotherAncestry.map(function(iterator) {
  17.   return iterator.born - byName[iterator.mother].born
  18. });
  19.  
  20. console.log(average(arrayMomsAgeAtBirth));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top