Created
December 14, 2016 01:46
-
-
Save AndrewRayCode/d9b611c2f7b8ce770c3cf43937e72115 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const newStats = days.map( day => ({ stats: day.statistics.breakdown.byTurnover }) ).reduce(function (pastDay, currentDay) { | |
const nextStats = currentDay.stats.map(function(stat) { | |
const oldSold = pastDay.stats.find(function (old) { | |
return old.name === stat.name; | |
}); | |
const newSold = stat.sold + oldSold.sold; | |
stat.sold = newSold; | |
return stat; | |
}); | |
return { | |
stats: nextStats, | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment