I have a object that looks like this:
const people = {
men: 4,
women: 2,
total: 6,
participants: {
1: 4,
2: 1,
3: 0
}
};
I am trying to achieve such result:
1 participants count 4
2 participants count 1
3 participants count 0 <- Hide me if count === 0
What is the best way to achieve this? using map
or forEach
or for
loop? Any help is appreciated, I have tried:
for (let key in people.participants) {
console.log("count",people.participants[key],"key",key;
}
which seems to be working except I cannot use it in React component like i would with map
...