I have an array of objects and I want to push only the values of each object inside the array to a new object as a key value pair using Javascript.
eg:
const prices = [
{ ticker: 'msft', price: 14.3 },
{ ticker: 'msft', price: 10.2 },
{ ticker: 'ibm', price: 9.2 },
{ ticker: 'amzn', price: 10.2 },
];
Output should be as below:
{
"msft":[10.2,14.3],
"ibm":[9.2],
"amzn":[10.2]
}