I have a matrix response array:
matrixArray = [
{Responded: 1, RowName: row1, ColName: col1},
{Responded: 2, RowName: row1, ColName: col2},
{Responded: 0, RowName: row1, ColName: col3},
{Responded: 0, RowName: row2, ColName: col1},
{Responded: 0, RowName: row2, ColName: col2},
{Responded: 1, RowName: row2, ColName: col3},
{Responded: 1, RowName: row3, ColName: col1},
{Responded: 0, RowName: row3, ColName: col2},
{Responded: 1, RowName: row3, ColName: col3},
...
...
];
It tells that how many times a column has been responded for a row. I need above array of objects in the following format:
matrixArray = [
{
RowName: row1,
col1: 1, //Here '1' is no. of times column responded
col2: 2,
col3: 0
},
{
RowName: row2,
col1: 0,
col2: 0,
col3: 1
},
{
RowName: row3,
col1: 1,
col2: 0,
col3: 1
},
];
I am using TypeScript for this. Thanks.