My array:
[
{
name: 'test1',
state: 'OK',
status: true,
pending: 33,
approved: 0,
active: 0,
inactive: 33
},
{
name: 'test3',
state: 'OK',
status: true,
pending: 33,
approved: 0,
active: 0,
inactive: 33
},
{
name: 'test4',
state: 'OK',
status: true
}
]
If the "pending", "approved", "active", "inactive" key not exists in object, i need output like this:
Expected output:
[
{
name: 'test1',
state: 'OK',
status: true,
pending: 33,
approved: 0,
active: 0,
inactive: 33
},
{
name: 'test3',
state: 'OK',
status: true,
pending: 33,
approved: 0,
active: 0,
inactive: 33
},
{
name: 'test4',
state: 'OK',
status: true,
pending: 0,
approved: 0,
active: 0,
inactive: 0
}
]
How to do this?
I tried with map but i dont know how to set condition.
I want to set the values into zero.