I need to push 0 in users element if the array's length is less than 7.
Example: If array has 2 elements. The rest should have 0 in it's users and _id as the index number.
Please help me to acheive this
const newUsers = [
{
_id: 1,
users: 8
},
{
_id: 2,
users: 6
},
{
_id: 3,
users: 1
},
{
_id: 4,
users: 8
},
{
_id: 5,
users: 0
},
{
_id: 7,
users: 0
}
]