I am trying to remove each user that does not have a firstName and lastName.
This is the object:
users = [{firstName: "john", lastName: "smith"}, {firstName: "", lastName: ""}]
This is my code:
let users = this.users.map(user => {
if (user.firstName !== '' && user.lastName !== '') {
return user
}
})
It does remove the empty ones, but it replaces it with null, and I want to completely remove it and not display null instead of the object.
What I get when I log it the mapped array: [{firstName: "john", lastName: "smith"}, null]