I have an array of array of objects. I want to reduce that to an array of object and adding one more property to each object. The sample input is:
const data = [
[
{name:"a", val:5},
{name:"b", val:10},
{name:"c", val:20},
{name:"d", val:50},
{name:"e", val:100}
],
[
{name:"a", val:0},
{name:"b", val:20},
{name:"c", val:30},
{name:"d", val:40},
{name:"e", val:10}
],
[
{name:"a", val:60},
{name:"b", val:50},
{name:"c", val:40},
{name:"d", val:70},
{name:"e", val:30}
]
];
And the Output should be:
[{name: 'a', val: 65, rank: 'si'},
{name: 'b', val: 80, rank: 'dp'},
{name: 'c', val: 90, rank: 'en'}
{name: 'd', val: 160, rank: 'fr'}]
Rank is static text means for a, it will always be "si"
How can I achieve this using ramda?
rankis generated? Grouping and summing is covered by a few different questions: using ramda group by property and sum results on specified property, Grouping and summing in Ramda.js, How to group by a key and sum other keys with Ramda?btotal is incorrect and should be 80 instead of 90 if you follows that pattern, I have to ask are those actually sums or is there some other algorithm?