I'm new in a react js and I want write a function that passed data as object(data is object {} )to get all q1 to q5 as price and p1 to p5 as vol finally I need to return new object ,this is my code here
const myfunction = ({ data }) => {
const myData = [];
for (let i = 1; i < 5 + 1; i += 1) {
const obj = {};
obj.price = data['q' + i];
obj.vol = data['p' + i];
myData.push(obj);
}
return {
name: 'ss',
color: '#ffff',
data: myData,
};
};