Created
November 19, 2012 20:17
-
-
Save munro/4113607 to your computer and use it in GitHub Desktop.
Where to eat!
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 results = _.reduce({ | |
marissa: {pho: 0, thai: 1, rauls: 1, racoon: 0.5}, | |
robert: {pho: 0, thai: 0.5, rauls: 1, racoon: 1}, | |
david: {pho: 1, thai: 0.8, rauls: 0.1, racoon: 0.6}, | |
tyler: {pho: 0.4, thai: 0.3, rauls: 0.7, racoon: 0.6}, | |
ryan: {pho: 0.8, thai: 0.8, rauls: 0.8, racoon: 0.6} | |
}, function (a, b) { | |
return { | |
pho: a.pho + b.pho, | |
thai: a.thai + b.thai, | |
rauls: a.rauls + b.rauls, | |
racoon: a.racoon + b.racoon, | |
count: (a.count || 1) + (b.count || 1) | |
}; | |
}); | |
console.log({ | |
pho: results.pho / results.count, | |
thai: results.thai / results.count, | |
rauls: results.rauls / results.count, | |
racoon: results.racoon / results.count | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment