I have this initial array:
const initialData = [
{
day: 1,
values: [
{
name: 'Roger',
score: 90,
},
{
name: 'Kevin',
score: 88,
},
{
name: 'Steve',
score: 80,
},
],
},
{
day: 2,
values: [
{
name: 'Roger',
score: 70,
},
{
name: 'Michael',
score: 88,
},
],
},
{
day: 3,
values: [
{
name: 'Steve',
score: 97,
},
],
},
];
to be converted into:
const result = [
{
name: 'Roger',
scores: [90, 70, null],
},
{
name: 'Kevin',
scores: [88, null, null],
},
{
name: 'Steve',
scores: [80, null, 97],
},
{
name: 'Michael',
scores: [null, 88, null],
},
];
I'm trying to use array map and create temporary array:
const holder = [];
initialData.map()
but to no avail