I have an array of objects:
const arr = [
{
name: 'John',
money: 45
},
{
name: 'Lui',
money: 65
},
{
name: 'Kegan',
money: 100
},
... isNewUser ? {
name: 'Eric',
money: 90
} : {}
]
I need to conditionally add the object when it is declared not using array.push. I've tried using the && operator but I just got errors.isNewUser is a boolean variable and if true, array should have 4 items, else the array should only have 3 which doesn't include the newUser object