i have input like below,
const data = [
{
id: 1,
count: 3,
},
{
id: 2,
count: 5,
},
];
now i want to gets the ids in a seperate array and sum of count.
so the expected output should be like below,
const ids = [1, 2];
const sum = 8; // which is the sum of count 3 and 5.
i have tried something like
const ids = data.map(({id: any}) => id; //[1,2]
const count = data.map(({count: any}) => count; // [3,5]
but how to get ids and sum of count in one step rather than this. also instead of type any what should be the correct types. i am new to programmming and typescript. could someone help me with this. thanks.