I got object from firebase like this way and i need to convert into an array i used a foreach with map but i didn't get success. i got 0 length of an array.
0: {id: "1", name: "Fever"}
1: {id: "2", name: "Cough"}
2: {id: "3", name: "Headache"}
3: {id: "4", name: "Stomach Pain"}
i used below method but it's not working
let result = [];
arr.forEach(item => {
let resObj = result.find(resObj => resObj.Name === item.Name);
resObj ? resObj.Count++ : result.push({'Name':item.Name, 'Value': item.Value, 'Count': 1});
});
console.log(result);
i need the output like this
[
{id: "1", name: "Fever"},{id: "2", name: "Cough"},{id: "3", name: "Headache"},{id: "4", name: "Stomach Pain"}
]
'Value': item.Valuein your code but in your array you have only two keys:id&name. Please post a minimal reproducible example.const result = Object.values(your_object)