I have an user object like this
user: {
name: "james",
contact: "3245234545",
email: "[email protected]"
}
and I want to display it like this
james, 3245234545, [email protected]
if it's an array I can do join(',') but it's an object unfortunately. My current approach is like this
{this.user &&
<div>
{this.user.name} ,{this.user.contact}, {this.user.email}
</div>
}
This will work but not perfect, what if user did not fill in their contact? then the extra , is still there. if the email is optional, then there will be an extra , too in the end.